Submission #180304

#TimeUsernameProblemLanguageResultExecution timeMemory
180304rzbtBigger segments (IZhO19_segments)C++14
13 / 100
2 ms400 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 500005 typedef long long ll; using namespace std; ll n; ll mz=0; ll tz=0; ll res=0; ll niz[MAXN]; pair<ll,ll> dp[MAXN]; ll pref[MAXN]; ll bin(ll l,ll d,ll sol,ll tren){ if(l>d)return sol; ll mid=(l+d)/2; if(pref[tren]-pref[mid]>=dp[mid].F)return bin(mid+1,d,mid,tren); return bin(l,mid-1,sol,tren); } int main() { scanf("%d", &n); for(ll i=1;i<=n;i++){ scanf("%d",niz+i); pref[i]=pref[i-1]+niz[i]; } //dp[i]=mp(pref[i],1); for(ll i=1;i<=n;i++){ ll koji=bin(1,i-1,0,i); //printf(" %d %d %d %d",i,koji) dp[i]=mp(pref[i]-pref[koji],dp[koji].S+1); } printf("%d",dp[n].S); return 0; }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:31:19: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll* {aka long long int*}' [-Wformat=]
     scanf("%d", &n);
                 ~~^
segments.cpp:33:25: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll* {aka long long int*}' [-Wformat=]
         scanf("%d",niz+i);
                    ~~~~~^
segments.cpp:43:24: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
     printf("%d",dp[n].S);
                        ^
segments.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
segments.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",niz+i);
         ~~~~~^~~~~~~~~~~~
#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...