Submission #499080

#TimeUsernameProblemLanguageResultExecution timeMemory
499080ismoilovBigger segments (IZhO19_segments)C++14
100 / 100
78 ms18916 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++) #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++) #define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--) #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--) void S() { int n; cin >> n; vector <int> a(n+1); fpp(i,1,n) cin >> a[i]; vector <ll> pr(n+2), b(n+2), d(n+2); fpp(i,1,n) pr[i] = pr[i-1] + a[i]; fpp(i,1,n){ b[i] = max(b[i-1], b[i]); d[i] = d[b[i]] + 1; ll c = 2*pr[i] - pr[b[i]]; int x = lower_bound(pr.begin()+1, pr.begin()+1+n, c) - pr.begin(); b[x] = max(b[x], i*1ll); } cout << d[n]; } int main() { IOS; S(); }

Compilation message (stderr)

segments.cpp: In function 'void S()':
segments.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
segments.cpp:15:2: note: in expansion of macro 'fpp'
   15 |  fpp(i,1,n)
      |  ^~~
segments.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
segments.cpp:18:2: note: in expansion of macro 'fpp'
   18 |  fpp(i,1,n)
      |  ^~~
segments.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
segments.cpp:20:2: note: in expansion of macro 'fpp'
   20 |  fpp(i,1,n){
      |  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...