Submission #146473

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1464732019-08-24 08:49:22achibasadzishviliBigger segments (IZhO19_segments)C++14
100 / 100
178 ms44372 KiB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a[500005],s[500005],ans[500005],ind;
vector<pair<ll,ll> >v[500005];
int main(){
ios::sync_with_stdio(false);
cin >> n;
for(int i=1; i<=n; i++){
cin >> a[i];
s[i] = s[i - 1] + a[i];
}
pair<ll,ll> p = make_pair(0 , 0);
for(int i=1; i<=n; i++){
for(int j=0; j<v[i].size(); j++)
if(v[i][j].f > p.f)
p = v[i][j];
else if(v[i][j].f == p.f)
p = max(p , v[i][j]);
ind = p.s;
ans[i] = ans[ind] + 1;
pair<ll,ll> ne = make_pair(ans[i] , i);
ll l = i + 1,r = n,mid,ik = -1;
while(r >= l){
mid = (l + r) / 2;
if(s[mid] - s[i] >= s[i] - s[ind]){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:19:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0; j<v[i].size(); j++)
                      ~^~~~~~~~~~~~
#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...