Submission #246786

#TimeUsernameProblemLanguageResultExecution timeMemory
246786Vladikus004Nizin (COCI16_nizin)C++14
100 / 100
77 ms10232 KiB
#include <bits/stdc++.h> #define int long long #define inf 2e9 #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef long double ld; typedef pair <int, int> pii; const int N = 1000000 + 3; int n, a[N], sum, nsum; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif // LOCAL cin >> n; int mn = inf; for (int i = 0; i < n; i++) { cin >> a[i]; } int i1 = 0, i2 = n - 1; int ans = 0; while (i1 < i2){ int j1 = i1, j2 = i2, sum1 = a[i1], sum2 = a[i2]; while (j1 < j2 && sum1 != sum2){ while (sum1 < sum2 && j1 < j2) sum1 += a[++j1], ans++; while (sum2 < sum1 && j1 < j2) sum2 += a[--j2], ans++; } i1 = j1 + 1; i2 = j2 - 1; } cout << ans; }

Compilation message (stderr)

nizin.cpp: In function 'int32_t main()':
nizin.cpp:21:9: warning: unused variable 'mn' [-Wunused-variable]
     int mn = inf;
         ^~
#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...