# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
839345 |
2023-08-29T19:03:26 Z |
emkow |
Teams (CEOI11_tea) |
C++14 |
|
306 ms |
86472 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#define pb emplace_back
#define ins insert
#define ssize(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pld pair <ld, ld>
#define st first
#define nd second
using namespace std;
using ll = int_fast64_t;
// using lll = __int128_t;
using ld = long double;
const int oo = 1e9 + 7;
const int mod = 1e9 + 7;
void solve(){
int n; cin >> n;
vector <pii> arr(n + 1);
for(int i = 1; i <= n; i ++){
cin >> arr[i].st;
arr[i].nd = i;
}
sort(all(arr));
vector <int> dp(n + 1, 0);
for(int i = 1; i <= n; i ++){
if(i == n){
dp[i] = dp[i - arr[i].st] + 1;
continue;
}
if(arr[i].st > i) dp[i] = dp[i - 1];
else dp[i] = max(dp[i - 1], dp[i - arr[i].st] + 1);
}
vector <vector<int>> ans;
priority_queue <pii> pq;
for(int i = n; i >= 1; i --){
if(i == n || (arr[i].st <= i && dp[i - arr[i].st] + 1 >= dp[i - 1])){
ans.pb();
for(int j = i; j >= i - arr[i].st + 1; j --) ans.back().pb(arr[j].nd);
pq.emplace(- ssize(ans.back()), ssize(ans) - 1);
i -= arr[i].st - 1;
continue;
}
pii rn = pq.top();
pq.pop();
ans[rn.nd].pb(arr[i].nd);
pq.emplace(- ssize(ans[rn.nd]), rn.nd);
}
cout << ssize(ans) << '\n';
for(auto i: ans){
cout << ssize(i) << ' ';
for(auto j: i) cout << j << ' ';
cout << '\n';
}
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int t; t = 1;
// cin >> t;
while(t --) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2636 KB |
Output is correct |
2 |
Correct |
15 ms |
2516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2900 KB |
Output is correct |
2 |
Correct |
17 ms |
2504 KB |
Output is correct |
3 |
Correct |
18 ms |
2892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
19968 KB |
Output is correct |
2 |
Correct |
152 ms |
21612 KB |
Output is correct |
3 |
Correct |
160 ms |
19672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
25472 KB |
Output is correct |
2 |
Correct |
306 ms |
86472 KB |
Output is correct |
3 |
Correct |
206 ms |
27976 KB |
Output is correct |
4 |
Correct |
192 ms |
22756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
227 ms |
27260 KB |
Output is correct |
2 |
Correct |
165 ms |
29420 KB |
Output is correct |
3 |
Correct |
198 ms |
25792 KB |
Output is correct |
4 |
Correct |
220 ms |
25664 KB |
Output is correct |