# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
345341 |
2021-01-07T07:45:24 Z |
koketsu |
Gift (IZhO18_nicegift) |
C++14 |
|
2000 ms |
212792 KB |
#include <bits/stdc++.h>
#define pb push_back
#define LL long long
#define Kultivator ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const LL Mxn = 1e6 + 7;
const LL Mod = 1e9 + 7;
const LL Inf = 1e14 + 7;
LL N, A, K, Dum;
vector <vector <pair <int, int>>> Ans;
set <pair <int, int>> St;
int main() {
Kultivator;
cin >> N >> K;
for(int i = 1; i <= N; i++){
cin >> A;
St.insert({-A, i});
Dum += A;
}
if(Dum % K) return cout << -1, 0;
while(!St.empty()){
vector <pair <int, int>> Bam;
for(int i = 1; i <= K; i++){
if(!St.size()) return cout << -1, 0;
pair <int, int> w = *(St.begin());
St.erase(St.begin());
Bam.pb({w.first + 1, w.second});
}
Ans.pb(Bam);
for(pair <int, int> i : Bam){
if(i.first) St.insert({i.first, i.second});
}
}
cout << Ans.size() << '\n';
for(int i = 0; i < Ans.size(); i++){
cout << 1 << ' ';
for(int j = 0; j < Ans[i].size(); j++){
cout << Ans[i][j].second << ' ';
}
cout << '\n';
}
}
Compilation message
nicegift.cpp: In function 'int main()':
nicegift.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0; i < Ans.size(); i++){
| ~~^~~~~~~~~~~~
nicegift.cpp:43:26: 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 | for(int j = 0; j < Ans[i].size(); j++){
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
512 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
500 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
512 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
500 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
9 ms |
1192 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
43 ms |
5408 KB |
n=50000 |
12 |
Correct |
42 ms |
5536 KB |
n=50000 |
13 |
Correct |
35 ms |
3636 KB |
n=10 |
14 |
Correct |
32 ms |
3232 KB |
n=685 |
15 |
Correct |
34 ms |
3416 KB |
n=623 |
16 |
Correct |
19 ms |
2084 KB |
n=973 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
512 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
500 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
9 ms |
1192 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
43 ms |
5408 KB |
n=50000 |
12 |
Correct |
42 ms |
5536 KB |
n=50000 |
13 |
Correct |
35 ms |
3636 KB |
n=10 |
14 |
Correct |
32 ms |
3232 KB |
n=685 |
15 |
Correct |
34 ms |
3416 KB |
n=623 |
16 |
Correct |
19 ms |
2084 KB |
n=973 |
17 |
Correct |
31 ms |
2596 KB |
n=989 |
18 |
Correct |
15 ms |
1260 KB |
n=563 |
19 |
Correct |
25 ms |
1772 KB |
n=592 |
20 |
Correct |
23 ms |
1644 KB |
n=938 |
21 |
Correct |
18 ms |
1516 KB |
n=747 |
22 |
Correct |
21 ms |
1516 KB |
n=991 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2073 ms |
212792 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
512 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
500 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
9 ms |
1192 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
43 ms |
5408 KB |
n=50000 |
12 |
Correct |
42 ms |
5536 KB |
n=50000 |
13 |
Correct |
35 ms |
3636 KB |
n=10 |
14 |
Correct |
32 ms |
3232 KB |
n=685 |
15 |
Correct |
34 ms |
3416 KB |
n=623 |
16 |
Correct |
19 ms |
2084 KB |
n=973 |
17 |
Correct |
31 ms |
2596 KB |
n=989 |
18 |
Correct |
15 ms |
1260 KB |
n=563 |
19 |
Correct |
25 ms |
1772 KB |
n=592 |
20 |
Correct |
23 ms |
1644 KB |
n=938 |
21 |
Correct |
18 ms |
1516 KB |
n=747 |
22 |
Correct |
21 ms |
1516 KB |
n=991 |
23 |
Execution timed out |
2073 ms |
212792 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |