# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494224 | nickmet2004 | Bigger segments (IZhO19_segments) | C++11 | 0 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 5e5 + 5;
int n , a[N];
main (){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i = 1; i<= n;++i)cin >> a[i];
int x = a[1] , i = 2;
set<int> s; int ans = 1;
while(i <= n){
int y =0;
while(i<=n && x > y + a[i])y+=a[i] , ++i ,s.insert(y);
y+=a[i];
//cout << y << " y" << endl;
ans++;
int z = (y - x)/2;
auto it = s.lower_bound(z);
if(it != s.end()){
if(*it == z) y-=z;
else{
if(it != s.begin())--it , y-=*it;
}
}
s.clear();
x = y;
//cout << x << " x" <<endl;
++i;
}cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |