# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
530198 | 2022-02-24T19:11:16 Z | peuch | Teams (CEOI11_tea) | C++17 | 234 ms | 24180 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4172 KB | Output is correct |
2 | Correct | 2 ms | 4172 KB | Output is correct |
3 | Correct | 2 ms | 4172 KB | Output is correct |
4 | Correct | 2 ms | 4172 KB | Output is correct |
5 | Correct | 2 ms | 4172 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4172 KB | Output is correct |
2 | Correct | 3 ms | 4172 KB | Output is correct |
3 | Correct | 2 ms | 4172 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4172 KB | Output is correct |
2 | Correct | 2 ms | 4176 KB | Output is correct |
3 | Correct | 2 ms | 4176 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4300 KB | Output is correct |
2 | Correct | 3 ms | 4304 KB | Output is correct |
3 | Correct | 3 ms | 4304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4300 KB | Output is correct |
2 | Correct | 3 ms | 4300 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 6000 KB | Output is correct |
2 | Correct | 21 ms | 6168 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 6248 KB | Output is correct |
2 | Correct | 23 ms | 6304 KB | Output is correct |
3 | Correct | 28 ms | 6132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 224 ms | 21608 KB | Output is correct |
2 | Correct | 200 ms | 24180 KB | Output is correct |
3 | Correct | 234 ms | 22224 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 191 ms | 24104 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 194 ms | 24108 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |