# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
673749 | meoww | Teams (CEOI11_tea) | C++14 | 1505 ms | 74696 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;
signed main() {
int n; cin>>n;
pair<int,int> v[n];
for (int i=0;i<n;i++) {
cin>>v[i].first;
v[i].second=i;
}
sort(v,v+n);
vector<vector<int> > tms;
int j=n-1;
for (int i=n-1;i>=0;i--) {
int nm=v[i].first;
vector<int> tmp;
while (j>=0 && nm>0) {
tmp.push_back(v[j].second); nm--;
j--;
}
if (nm>0) {
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
for (int p=0;p<tms.size();p++) pq.push({tms[p].size(),p});
int ntmp=0;
while (ntmp<tmp.size()) {
int ii=pq.top().second;
tms[ii].push_back(tmp[ntmp]);
ntmp++;
pq.pop();
pq.push({tms[ii].size(),ii});
}
}
else {
tms.push_back(tmp);
i=j+1;
}
}
cout<<tms.size()<<endl;
for (int i=0;i<tms.size();i++) {
cout<<tms[i].size()<<' ';
for (int j:tms[i]) cout<<j+1<<' ';
cout<<endl;
}
}
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... |