제출 #667798

#제출 시각아이디문제언어결과실행 시간메모리
667798Kaztaev_AlisherGift (IZhO18_nicegift)C++17
30 / 100
1230 ms238468 KiB
//#pragma GCC optomize ("Ofast")
//#pragma GCC optomize ("unroll-loops")
//#pragma GCC target ("avx,avx2,fma")

#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz size
#define cl clear
#define ins insert
#define ers erase
#define pii pair < int , int >
#define pll pair< long long  , long long >
#define all(x) x.begin() , x.end()
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define tostr(x) to_string(x)
#define tonum(s) atoi(s.c_str())
#define seon(x) setprecision(x)
#define bpop(x) __builtin_popcount(x)
#define deb(x) cerr << #x  << " = " << x << endl;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
const double PI = 3.14159265;

const ll N = 1e6+5;
const ll mod = 1e9+7;
const ll inf = 1e9;
const ll INF = 1e18;

using namespace std;

set<pll>st;
pll b[N];
vector<int> v[N];
void solve(){
	ll n , k ,cnt = 0;
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		ll a;
		cin >> a;
		st.ins({a , i});
	}
	while(st.sz()){
		++cnt;
		if(st.sz() < k){
			cout << "-1\n";
			return;
		}
		for(int i = 1; i <= k; i++){
			b[i] = *st.rbegin();
			st.ers(*st.rbegin());
			v[cnt].pb(b[i].S);
		}
		for(int i = 1; i <= k; i++) {
			b[i].F--;
			if(b[i].F) st.ins({b[i].F , b[i].S});
		}
	}
	cout << cnt <<"\n";
	for(int i = 1; i <= cnt; i++){
		cout << 1 <<" ";
		for(int x : v[i]) cout << x <<" ";
		cout << "\n";
	}
}
signed main(){
	ios;
	solve();
	return 0;
}
/*
*/

컴파일 시 표준 에러 (stderr) 메시지

nicegift.cpp: In function 'void solve()':
nicegift.cpp:50:14: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   50 |   if(st.sz() < k){
      |      ~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...