답안 #1114649

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114649 2024-11-19T10:08:17 Z adiyer Gift (IZhO18_nicegift) C++17
30 / 100
2000 ms 236892 KB
#include <bits/stdc++.h>

#define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) (x.begin(), x.end())
#define pb push_back

// #define int long long

typedef long long ll;

using namespace std;

const int N = 1e6 + 11;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 11;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll n, k;
ll a[N];

set < pair < ll, ll >, greater < pair < ll, ll > > > st;

vector < vector < ll > > ans;

void solve(){
	cin >> n >> k;
	for(ll i = 1; i <= n; i++) cin >> a[i], st.insert({a[i], i});
	while(st.size() >= k){
		vector < ll > pos = {1};
		vector < pair < ll, ll > > del;
		for(auto it : st){ 
			del.pb(it); 
			pos.pb(it.second);
			if(del.size() == k) break;
		}
		for(auto it : del) st.erase(it);
		for(auto it : del) st.insert({it.first - 1, it.second});
		while(st.size() && (st.rbegin() -> first) == 0) st.erase(*st.rbegin());
		ans.pb(pos);
	}
	if(st.empty()){
		cout << ans.size() << '\n';
		for(auto it : ans){
			for(ll x : it) cout << x << ' ';
			cout << '\n';
		}
	}
	else{
		cout << -1;
	}
}

const bool Cases = 0;

signed main(){
	adiyer();
	int CS = 1;
	if(Cases) cin >> CS;
	while(CS--) solve();
}

Compilation message

nicegift.cpp: In function 'void solve()':
nicegift.cpp:29:18: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   29 |  while(st.size() >= k){
      |        ~~~~~~~~~~^~~~
nicegift.cpp:35:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   35 |    if(del.size() == k) break;
      |       ~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 336 KB n=3
4 Correct 1 ms 336 KB n=4
5 Correct 1 ms 336 KB n=4
6 Correct 1 ms 336 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 336 KB n=3
4 Correct 1 ms 336 KB n=4
5 Correct 1 ms 336 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 7 ms 988 KB n=8
9 Correct 8 ms 1164 KB n=14
10 Correct 4 ms 1104 KB n=11
11 Correct 42 ms 8444 KB n=50000
12 Correct 43 ms 8444 KB n=50000
13 Correct 23 ms 3536 KB n=10
14 Correct 26 ms 3092 KB n=685
15 Correct 25 ms 3332 KB n=623
16 Correct 14 ms 2056 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 336 KB n=3
4 Correct 1 ms 336 KB n=4
5 Correct 1 ms 336 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 7 ms 988 KB n=8
9 Correct 8 ms 1164 KB n=14
10 Correct 4 ms 1104 KB n=11
11 Correct 42 ms 8444 KB n=50000
12 Correct 43 ms 8444 KB n=50000
13 Correct 23 ms 3536 KB n=10
14 Correct 26 ms 3092 KB n=685
15 Correct 25 ms 3332 KB n=623
16 Correct 14 ms 2056 KB n=973
17 Correct 25 ms 3080 KB n=989
18 Correct 11 ms 1360 KB n=563
19 Correct 17 ms 1872 KB n=592
20 Correct 18 ms 1872 KB n=938
21 Correct 14 ms 1456 KB n=747
22 Correct 16 ms 1732 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2073 ms 236892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 336 KB n=3
4 Correct 1 ms 336 KB n=4
5 Correct 1 ms 336 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 7 ms 988 KB n=8
9 Correct 8 ms 1164 KB n=14
10 Correct 4 ms 1104 KB n=11
11 Correct 42 ms 8444 KB n=50000
12 Correct 43 ms 8444 KB n=50000
13 Correct 23 ms 3536 KB n=10
14 Correct 26 ms 3092 KB n=685
15 Correct 25 ms 3332 KB n=623
16 Correct 14 ms 2056 KB n=973
17 Correct 25 ms 3080 KB n=989
18 Correct 11 ms 1360 KB n=563
19 Correct 17 ms 1872 KB n=592
20 Correct 18 ms 1872 KB n=938
21 Correct 14 ms 1456 KB n=747
22 Correct 16 ms 1732 KB n=991
23 Execution timed out 2073 ms 236892 KB Time limit exceeded
24 Halted 0 ms 0 KB -