# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758235 | 2023-06-14T09:59:29 Z | vjudge1 | Money (IZhO17_money) | C++17 | 0 ms | 236 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const int mxN = 1e6 + 7; int n, arr[mxN]; int rec(int i, vector<vector<int>> vec) { if (i == n) { bool ok = true; set<int> cur; for (int i = 0; i < vec.size() && ok; ++i) { assert(vec[i].size()); auto it1 = cur.upper_bound(vec[i][0]); auto it2 = cur.upper_bound(vec[i].back()); if (it1 != it2) { ok = false; } for (auto x : vec[i]) { cur.insert(x); } } return (ok ? vec.size() : n); } int res = n; if (vec.size() && vec.back().back() < arr[i]) { vec.back().push_back(arr[i]); res = min(res, rec(i + 1, vec)); vec.back().pop_back(); } vec.push_back({arr[i]}); return min(res, rec(i + 1, vec)); } int32_t main() { //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; ++i) { cin >> arr[i]; } cout << rec(0, {}); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 236 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 236 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 236 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 236 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |