[cf660c] Hard Process (ruler)

Source: Internet
Author: User

Title Link: Http://codeforces.com/problemset/problem/660/C

Ruler, each time you encounter 0 of the time to fill a 1, until the completion or out of bounds. Each time a 0 point is recycled from left to right. The recording path is jammed with two pointers, each updated.

1#include <algorithm>2#include <iostream>3#include <iomanip>4#include <cstring>5#include <climits>6#include <complex>7#include <fstream>8#include <cassert>9#include <cstdio>Ten#include <bitset> One#include <vector> A#include <deque> -#include <queue> -#include <stack> the#include <ctime> -#include <Set> -#include <map> -#include <cmath> +  - using namespacestd; +  A Const intMAXN =666666; at intN, K; - intA[MAXN]; -  - intMain () { -     //freopen ("in", "R", stdin); -      while(~SCANF ("%d%d", &n, &k)) { in          for(inti =1; I <= N; i++) { -scanf"%d", &a[i]); to         } +         intLL =1; -         intRR =1; the         intAl =0; *         intAR =0; $         intCur =0;Panax Notoginseng         intAns =0; -          while(1) { the             if(RR > N) Break; +              while(RR <= n && cur <=k) { A                 if(A[RR] = =0) { the                     if(cur = = k) Break; +cur++; -                 } $rr++; $             } -             if(Rr-ll >ans) { -Ans = rr-ll; theAl =ll; -AR = RR-1;Wuyi             } the              while(ll <= rr && a[ll] = =1) ll++; -cur--; Wull++; -         } Aboutprintf"%d\n", ans); $          for(inti =1; I <= N; i++) { -             if(I >= al && i <= ar) printf ("1"); -             Elseprintf"%d", A[i]); -         } Aprintf"\ n"); +     } the     return 0; -}

[cf660c] Hard Process (ruler)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.