Submission #208884

#TimeUsernameProblemLanguageResultExecution timeMemory
208884SenseiNizin (COCI16_nizin)C++14
0 / 100
128 ms14200 KiB
/* DATE: 2020-03-12 14:19:25 NAME: PROBLEM: COCI16_NIZIN */ #include <bits/stdc++.h> using namespace std; const int MAXN = 1e6; int a[MAXN + 7]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } deque<long long> dq; dq.insert(dq.begin(), a + 1, a + n + 1); int ans = 0; while (dq.size() > 0) { if (dq.front() == dq.back()) { dq.pop_front(); dq.pop_back(); } else if (dq.front() > dq.back()) { long long x = dq.back(); dq.pop_back(); dq.back() += x; ans++; } else { long long x = dq.front(); dq.pop_front(); dq.front() += x; ans++; } } cout << ans << "\n"; return 0; }

Compilation message (stderr)

nizin.cpp: In function 'int main()':
nizin.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a[i]);
     ~~~~~^~~~~~~~~~~~~
#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...