Submission #317284

# Submission time Handle Problem Language Result Execution time Memory
317284 2020-10-29T09:38:46 Z shrek12357 Teams (CEOI11_tea) C++14
0 / 100
344 ms 33512 KB
#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

tea.cpp: In function 'int main()':
tea.cpp:35:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::priority_queue<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   if (cur <= pq.size()) {
      |       ~~~~^~~~~~~~~~~~
tea.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  for (int i = 0; i < ans.size(); i++) {
      |                  ~~^~~~~~~~~~~~
tea.cpp:53:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   for (int j = 0; j < ans[i].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 3056 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 3312 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 229 ms 22996 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 306 ms 32096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 344 ms 33512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -