# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209111 | ArKCa | Nizin (COCI16_nizin) | C++17 | 122 ms | 8184 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 f1 first
#define s2 second
#define pb push_back
#define pob pop_back
#define int ll
#define ll long long
#define PII pair<int,int>
#define N 1000006
#define mod 1000000007
using namespace std;
int n,arka,on,arkasum,onsum,ans;
int dizi[N];
int32_t main(){
// freopen("a.gir","r",stdin);
// freopen("a.cik","w",stdout);
//
//
scanf("%lld" ,&n);
for(int i=0;i<n;i++){
scanf("%lld",&dizi[i]);
}
arka=0;
on=n-1;
arkasum=0;
onsum=0;
while(on>arka){
if(dizi[on]==dizi[arka]){
on--;
arka++;
arkasum=0;
onsum=0;
continue;
}
arkasum+=dizi[arka];
arka++;
onsum+=dizi[on];
on--;
while(arkasum!=onsum && on>=arka ){
// printf("%lld %lld %lld %lld\n",on,arka,onsum,arkasum );
if(onsum>arkasum){
arkasum+=dizi[arka];
arka++;
}
else{
onsum+=dizi[on];
on--;
}
ans++;
// printf("%lld %lld %lld %lld\n\n",on,arka,onsum,arkasum );
}
if(arkasum!=onsum && on<arka)ans++;
arkasum=0;
onsum=0;
}
printf("%lld\n", 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... |
# | 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... |