# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530138 | peuch | Teams (CEOI11_tea) | C++17 | 598 ms | 119812 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int n;
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);
for(int i = 1; i <= n; i++){
int cur = v[i].second;
int qnt = v[i].first;
if(qnt > n - i + 1){
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |