Submission #493897

#TimeUsernameProblemLanguageResultExecution timeMemory
493897KarabasanNizin (COCI16_nizin)C++17
10 / 100
62 ms6068 KiB
#include <bits/stdc++.h> #define ll long long #define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,avx") #pragma GCC optimize("unroll-loops") int n; int dizi[1000005]; void solve() { cin>>n; for(int i=1;i<=n;i++) cin>>dizi[i]; int i=1; int j=n; int cevap=0; while(i<j) { if(dizi[i]!=dizi[j]) { if(dizi[i]+dizi[i+1]==dizi[j]) { cevap++; i+=2; j--; } else if(dizi[j]+dizi[j-1]==dizi[i]) { cevap++; i++; j-=2; } else { cevap+=2; dizi[i+1]=dizi[i]+dizi[i+1]; dizi[j-1]=dizi[j]+dizi[j-1]; i++; j--; } } else { i++; j--; } } cout<<cevap; } signed main() { fast1 int t=1; //cin>>t; while(t--) { solve(); } return 0; }
#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...
#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...