# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
317284 | shrek12357 | Teams (CEOI11_tea) | C++14 | 344 ms | 33512 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 <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0);
int main() {
cin.tie(0);ios_base::sync_with_stdio(0);
int n;
cin >> n;
int counter = 0;
vector<int> nums;
priority_queue<pair<int, int>> pq;
priority_queue<pair<int, int>> groups;
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
pq.push({ temp, i });
}
vector<vector<int>> ans;
while (pq.size() > 0) {
int cur = pq.top().first, idx = pq.top().second;
pq.pop();
cur--;
if (cur <= pq.size()) {
vector<int> temp;
temp.push_back(idx);
ans.push_back(temp);
for (int i = 0; i < cur; i++) {
ans[counter].push_back(pq.top().second);
pq.pop();
}
counter++;
}
else {
int g = groups.top().second;
ans[g].push_back(idx);
}
}
cout << counter << endl;
for (int i = 0; i < ans.size(); i++) {
cout << ans[i].size() << " ";
for (int j = 0; j < ans[i].size(); j++) {
cout << ans[i][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... |