# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530200 | 2022-02-24T19:11:47 Z | peuch | Teams (CEOI11_tea) | C++17 | 363 ms | 33228 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 2e6 + 10; int n; int dp[MAXN], bt[MAXN]; pair<int, int> v[MAXN]; vector<vector<int> > group; set<pair<int, int> > tam; int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++){ scanf("%d", &v[i].first); v[i].second = i; } sort(v + 1, v + 1 + n); reverse(v + 1, v + 1 + n); memset(dp, -MAXN, sizeof(dp)); dp[n + 1] = 0; for(int i = n; i > 0; i--){ dp[i] = max(dp[i + 1], dp[i + v[i].first] + 1); if(i == 1) dp[i] = dp[i + v[i].first] + 1; if(dp[i] == dp[i + v[i].first] + 1) bt[i] = i + v[i].first; else bt[i] = i + 1; } for(int i = 1; i <= n; i++){ int cur = v[i].second; int qnt = v[i].first; if(bt[i] != i + qnt){ fflush(stdout); int grp = tam.begin()->second; tam.erase(tam.begin()); group[grp].push_back(cur); tam.insert(make_pair(group[grp].size(), grp)); continue; } group.push_back(vector<int> (1, cur)); int idx = group.size() - 1; while(--qnt) group[idx].push_back(v[++i].second); tam.insert(make_pair(group[idx].size(), idx)); } printf("%lu\n", group.size()); for(int i = 0; i < group.size(); i++){ printf("%lu ", group[i].size()); sort(group[i].begin(), group[i].end()); for(int j = 0; j < group[i].size(); j++) printf("%d ", group[i][j]); printf("\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 8012 KB | Output is correct |
2 | Incorrect | 3 ms | 8140 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 20] |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 8120 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 100] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 8080 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 200] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 8140 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 4999] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 8140 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 5000] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 ms | 9932 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 80005] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 30 ms | 10188 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 90003] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 224 ms | 25564 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 750013] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 304 ms | 31236 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 1000000] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 363 ms | 33228 KB | Integer parameter [name=k_j] equals to 0, violates the range [1, 1000000] |
2 | Halted | 0 ms | 0 KB | - |