답안 #263934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
263934 2020-08-14T04:21:11 Z 임성재(#5088) Teams (CEOI11_tea) C++17
0 / 100
338 ms 21104 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(); i += v[i].fi) {
		if(i + v[i].fi > v.size()) {
			l = i;
			break;
		}

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

		pQ.em(ans.back().size(), ans.size()-1);
	}

	for(int i=l; i<v.size(); i++) {
		auto j = pQ.top();
		pQ.pop();

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

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

	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(); i += v[i].fi) {
      |               ~~^~~~~~~~~~
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:49:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for(int j=i; j < i + v[i].fi && j < v.size(); j++) {
      |                                   ~~^~~~~~~~~~
tea.cpp:56:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for(int i=l; i<v.size(); i++) {
      |               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 1912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 2152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 236 ms 14804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 330 ms 19936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 338 ms 21104 KB Output isn't correct
2 Halted 0 ms 0 KB -