답안 #263952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
263952 2020-08-14T04:30:21 Z 임성재(#5088) Teams (CEOI11_tea) C++17
80 / 100
434 ms 80680 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define pre(a) cout << fixed; cout.precision(a);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

int n;
vector<pii> v;
vector<vector<int>> ans;
vector<int> x;
priority_queue<pii, vector<pii>, greater<pii>> pQ;

int main() {
	fast;

	cin >> n;

	for(int i=1; i<=n; i++) {
		int s;
		cin >> s;

		v.eb(s, i);
	}

	sort(all(v));
	reverse(all(v));

	int l = v.size();

	for(int i=0; i < v.size(); ) {
		if(i + v[i].fi > v.size()) {
			auto j = pQ.top();
			pQ.pop();

			ans[j.se].eb(v[i].se);

			pQ.em(j.fi+1, j.se);
			
			i++;

			continue;
		}

		ans.eb(x);
		for(int j=i; j < i + v[i].fi; j++) {
			ans.back().eb(v[j].se);
		}

		pQ.em(ans.back().size(), ans.size()-1);
		i += v[i].fi;
	}

	cout << ans.size() << "\n";
	for(auto i : ans) {
		cout << i.size() << " ";
		for(auto j : i) {
			cout << j << " ";
		}
		cout << "\n";
	}
}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:42:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i=0; i < v.size(); ) {
      |               ~~^~~~~~~~~~
tea.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   if(i + v[i].fi > v.size()) {
      |      ~~~~~~~~~~~~^~~~~~~~~~
tea.cpp:40:6: warning: unused variable 'l' [-Wunused-variable]
   40 |  int l = v.size();
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 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 23 ms 1912 KB Output is correct
2 Correct 22 ms 2328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2032 KB Output is correct
2 Correct 22 ms 2168 KB Output is correct
3 Correct 26 ms 2032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 14808 KB Output is correct
2 Correct 228 ms 19032 KB Output is correct
3 Correct 232 ms 20564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 310 ms 20008 KB Output is correct
2 Correct 434 ms 80680 KB Output is correct
3 Correct 294 ms 21992 KB Output is correct
4 Correct 310 ms 22228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 339 ms 21168 KB Output is correct
2 Correct 245 ms 23256 KB Output is correct
3 Correct 307 ms 19796 KB Output is correct
4 Correct 382 ms 25552 KB Output is correct