# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
947442 |
2024-03-16T07:32:31 Z |
vjudge1 |
Nizin (COCI16_nizin) |
C++17 |
|
52 ms |
10920 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
872 KB |
Output is correct |
2 |
Correct |
5 ms |
1404 KB |
Output is correct |
3 |
Correct |
5 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
3164 KB |
Output is correct |
2 |
Correct |
21 ms |
4700 KB |
Output is correct |
3 |
Correct |
24 ms |
5468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
6488 KB |
Output is correct |
2 |
Correct |
38 ms |
8540 KB |
Output is correct |
3 |
Correct |
42 ms |
9564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
8416 KB |
Output is correct |
2 |
Correct |
52 ms |
10920 KB |
Output is correct |
3 |
Correct |
47 ms |
10672 KB |
Output is correct |