Submission #320392

#TimeUsernameProblemLanguageResultExecution timeMemory
320392ryangohcaNizin (COCI16_nizin)C++17
100 / 100
177 ms10740 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int32_t main() { int n; cin >> n; deque<int> nums; for (int i = 0; i < n; i++){ int g; cin >> g; nums.push_back(g); } int ans = 0; while (nums.size() > 1){ if (nums.front() == nums.back()){ nums.pop_front(); nums.pop_back(); } else if (nums.back() < nums.front()){ int to_add = nums[nums.size() - 1] + nums[nums.size() - 2]; nums.pop_back(); nums.pop_back(); nums.push_back(to_add); ans++; } else { int to_add = nums[0] + nums[1]; nums.pop_front(); nums.pop_front(); nums.push_front(to_add); ans++; } } cout << ans << '\n'; }
#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...