# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336857 | 2020-12-17T05:27:01 Z | boykut | Bigger segments (IZhO19_segments) | C++14 | 40 ms | 492 KB |
#include <bits/stdc++.h> using namespace std; #define linl long long int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector < int > a(n); for (int & to : a) { cin >> to; } int max = 0; if (n <= 20) { for (int i = 0; i < (1 << (n - 1)); i++) { vector < int > mas(n, 0); mas[0] = 0; int num = i, index = n - 1; while (num) { mas[index] = num % 2; num /= 2; index--; } //for (int to : mas) cout << to; cout << '\n'; bool ok = true; for (int i = 0; i < n - 1 && ok; i++) { if (mas[i] == 1 && mas[i + 1] == 1) { ok = false; } } if (ok == false) continue; vector < int64_t > vec; int64_t sum = 0ll; bool ans = true; for (int i = 0; i < n; i++) { if (mas[i] == 1) { if (!vec.empty()) { if (sum < vec.back()) ans = false; } vec.push_back(sum); sum = 0; } sum += a[i]; } if (!vec.empty()) { if (sum < vec.back()) ans = false; } vec.push_back(sum); if (ans && vec.size() > max) max = vec.size(); } cout << max << '\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 33 ms | 492 KB | Output is correct |
5 | Incorrect | 40 ms | 364 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 33 ms | 492 KB | Output is correct |
5 | Incorrect | 40 ms | 364 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 33 ms | 492 KB | Output is correct |
5 | Incorrect | 40 ms | 364 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 33 ms | 492 KB | Output is correct |
5 | Incorrect | 40 ms | 364 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 33 ms | 492 KB | Output is correct |
5 | Incorrect | 40 ms | 364 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |