# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985677 | 2024-05-18T14:27:27 Z | rembocoder | Volontiranje (COCI21_volontiranje) | C++17 | 1000 ms | 9564 KB |
#include <bits/stdc++.h> using namespace std; #define int int64_t // const int mod = 1e9 + 7; const int inf = 2e18; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<bool> del(n, false); int ans = -1; vector<vector<int>> seqs; while (true) { vector<int> dp(n, -inf); for (int i = n - 1; i >= 0; i--) { if (del[i]) { continue; } dp[i] = 1; for (int j = i + 1; j < n; j++) { if (!del[j] && a[j] > a[i]) { dp[i] = max(dp[i], dp[j] + 1); } } } int cur = -inf; for (int i = 0; i < n; i++) { if (!del[i]) { cur = max(cur, dp[i]); } } if (ans == -1) { ans = cur; } else if (ans != cur) { break; } seqs.push_back({}); int last = -1; for (int i = 0; i < n; i++) { if (del[i] || dp[i] != cur || (last != -1 && a[i] <= a[last])) { continue; } last = i; cur--; seqs.back().push_back(i); del[i] = true; } } cout << seqs.size() << ' ' << ans << '\n'; for (int i = 0; i < seqs.size(); i++) { for (int x: seqs[i]) { cout << x + 1 << ' '; } cout << '\n'; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 3 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 456 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 160 ms | 344 KB | Output is correct |
31 | Correct | 6 ms | 344 KB | Output is correct |
32 | Correct | 8 ms | 348 KB | Output is correct |
33 | Correct | 79 ms | 480 KB | Output is correct |
34 | Correct | 70 ms | 468 KB | Output is correct |
35 | Correct | 76 ms | 476 KB | Output is correct |
36 | Correct | 2 ms | 344 KB | Output is correct |
37 | Correct | 2 ms | 348 KB | Output is correct |
38 | Correct | 3 ms | 452 KB | Output is correct |
39 | Correct | 1 ms | 344 KB | Output is correct |
40 | Correct | 0 ms | 348 KB | Output is correct |
41 | Correct | 0 ms | 348 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 1 ms | 348 KB | Output is correct |
44 | Correct | 0 ms | 348 KB | Output is correct |
45 | Correct | 0 ms | 348 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 3 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 456 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 160 ms | 344 KB | Output is correct |
31 | Correct | 6 ms | 344 KB | Output is correct |
32 | Correct | 8 ms | 348 KB | Output is correct |
33 | Correct | 79 ms | 480 KB | Output is correct |
34 | Correct | 70 ms | 468 KB | Output is correct |
35 | Correct | 76 ms | 476 KB | Output is correct |
36 | Correct | 2 ms | 344 KB | Output is correct |
37 | Correct | 2 ms | 348 KB | Output is correct |
38 | Correct | 3 ms | 452 KB | Output is correct |
39 | Correct | 1 ms | 344 KB | Output is correct |
40 | Correct | 0 ms | 348 KB | Output is correct |
41 | Correct | 0 ms | 348 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 1 ms | 348 KB | Output is correct |
44 | Correct | 0 ms | 348 KB | Output is correct |
45 | Correct | 0 ms | 348 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Execution timed out | 1038 ms | 9564 KB | Time limit exceeded |
48 | Halted | 0 ms | 0 KB | - |