Submission #947442

#TimeUsernameProblemLanguageResultExecution timeMemory
947442vjudge1Nizin (COCI16_nizin)C++17
100 / 100
52 ms10920 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; using ll = long long; const int maxN = 1e6 + 1; const int MOD = 1e9 + 7; int n; deque<ll> DQ; void ReadInput() { cin >> n; for (int i = 1; i <= n; i++) { ll x; cin >> x; DQ.push_back(x); } } void Solve() { ll res = 0; while (DQ.size() > 1) { if (DQ.front() == DQ.back()) { DQ.pop_back(); DQ.pop_front(); continue; } if (!DQ.empty()) { res++; int tmp; if (DQ.front() > DQ.back()) { tmp = DQ.back(); DQ.pop_back(); DQ.back() += tmp; } else { tmp = DQ.front(); DQ.pop_front(); DQ.front() += tmp; } } } cout << res; } #define task "" int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen(task".INP", "r", stdin); //freopen(task".OUT", "w", stdout); int T = 1; //cin >> T; while (T--) { ReadInput(); Solve(); } }
#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...