답안 #317285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
317285 2020-10-29T09:49:34 Z shrek12357 Teams (CEOI11_tea) C++14
70 / 100
2500 ms 82728 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>, vector<pair<int, int>>, greater<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();
			}
			groups.push({ ans[counter].size(), counter });
			counter++;
		}
		else {
			int g = groups.top().second;
			ans[g].push_back(idx);
			groups.pop();
			groups.push({ ans[g].size(), g });
		}
	}
	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:54:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for (int i = 0; i < ans.size(); i++) {
      |                  ~~^~~~~~~~~~~~
tea.cpp:56:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   for (int j = 0; j < ans[i].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1912 KB Output is correct
2 Correct 29 ms 2296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 2156 KB Output is correct
2 Correct 36 ms 2316 KB Output is correct
3 Correct 31 ms 2656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 277 ms 14932 KB Output is correct
2 Correct 344 ms 19028 KB Output is correct
3 Correct 283 ms 20564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 376 ms 20052 KB Output is correct
2 Execution timed out 2591 ms 82728 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 407 ms 20184 KB Output is correct
2 Correct 349 ms 30932 KB Output is correct
3 Correct 381 ms 23764 KB Output is correct
4 Correct 427 ms 25044 KB Output is correct