# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1111675 | 2024-11-12T14:54:39 Z | khoaha123 | Teams (CEOI11_tea) | C++17 | 392 ms | 262144 KB |
#include <bits/stdc++.h> #define endl '\n' #define ii pair<int,int> #define task "DIVTEAM" #define all(x) x.begin(),x.end() #define int long long using namespace std; const int N = 1e6 + 5; const int mod = 1e9 + 7; const int INF = 1e9; const double EPS = 1e-9; const int dx[2] = {1,0}; const int dy[2] = {0,1}; int n,a[N]; vector<int> b[N]; vector<vector<int>> ans; int dp[N],pos[N]; int check(int T){ dp[0] = 0; for (int i = 1; i <= n; ++i){ if (i >= a[i] && i - pos[i - a[i]] <= T) dp[i] = dp[pos[i - a[i]]] + 1; pos[i] = (dp[pos[i-1]] > dp[i] ? pos[i-1] : i); } return dp[n]; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); freopen(task".OUT","w",stdout); } cin >> n; for (int i = 1; i <= n; ++i){ cin >> a[i]; b[a[i]].push_back(i); } sort(a+1,a+1+n); int result = check(n); int l = 0,r = n; while (r - l > 1){ int mid = (l + r) >> 1; if (check(mid) == result) r = mid; else l = mid; } check(r); int u = n; while (u){ int t = pos[u -a[u]]; vector<int> x; while (u > t){ x.push_back(b[a[u]].back()); b[a[u]].pop_back(); u--; } ans.push_back(x); } cout << ans.size() << endl; for (auto f : ans){ cout << f.size() << ' '; for (auto g : f) cout << g << ' '; cout << endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 26960 KB | Output is correct |
2 | Incorrect | 5 ms | 26960 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 308 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 26960 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 306 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 325 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 333 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 308 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 392 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 383 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 284 ms | 136728 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |