# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
342673 |
2021-01-02T15:58:09 Z |
Rakhmand |
Gift (IZhO18_nicegift) |
C++14 |
|
2000 ms |
211464 KB |
//
// main.cpp
// torelax
//
// Created by Rakhman on 11/15/20.
//
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer {cout << "NO"; exit(0);}
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)
const long long mxn = 2e6 + 110;
const long long mnn = 1e1 + 1;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long OO = 1e11;
typedef long long llong;
typedef unsigned long long ullong;
using namespace std;
int n, k;
set<pair<int, int> > st;
llong sum = 0;
int main() {
cin >> n >> k;
for(int i = 1; i <= n; i++){
int x;
cin >> x;
st.insert({-x, i});
sum += x;
}
if(sum % k != 0){
cout << -1;
return 0;
}
vector<vector<pair<int, int> > > ans;
while(st.size() != 0){
vector<pair<int, int> > kek;
for(int i = 1; i <= k; i++){
if(st.size() == 0){
cout << -1;
return 0;
}
pair<int, int> x = *(st.begin());
st.erase(st.begin());
kek.push_back({x.F + 1, x.S});
}
ans.push_back(kek);
for(int i = 0; i < kek.size(); i++){
if(kek[i].F != 0){
st.insert({kek[i].F, kek[i].S});
}
}
}
cout << ans.size() << nl;
for(int i = 0; i < ans.size(); i++){
cout << 1 << ' ';
for(int j = 0; j < ans[i].size(); j++){
cout << ans[i][j].S << ' ';
}
cout << nl;
}
}
Compilation message
nicegift.cpp: In function 'int main()':
nicegift.cpp:82: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]
82 | for(int i = 0; i < kek.size(); i++){
| ~~^~~~~~~~~~~~
nicegift.cpp:89: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]
89 | for(int i = 0; i < ans.size(); i++){
| ~~^~~~~~~~~~~~
nicegift.cpp:91: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]
91 | for(int j = 0; j < ans[i].size(); j++){
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Correct |
0 ms |
364 KB |
n=4 |
5 |
Correct |
0 ms |
364 KB |
n=4 |
6 |
Correct |
0 ms |
364 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Correct |
0 ms |
364 KB |
n=4 |
5 |
Correct |
0 ms |
364 KB |
n=4 |
6 |
Correct |
0 ms |
364 KB |
n=2 |
7 |
Correct |
0 ms |
364 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
10 ms |
1192 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
51 ms |
5280 KB |
n=50000 |
12 |
Correct |
51 ms |
5664 KB |
n=50000 |
13 |
Correct |
32 ms |
3488 KB |
n=10 |
14 |
Correct |
42 ms |
3232 KB |
n=685 |
15 |
Correct |
39 ms |
3360 KB |
n=623 |
16 |
Correct |
21 ms |
2084 KB |
n=973 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Correct |
0 ms |
364 KB |
n=4 |
5 |
Correct |
0 ms |
364 KB |
n=4 |
6 |
Correct |
0 ms |
364 KB |
n=2 |
7 |
Correct |
0 ms |
364 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
10 ms |
1192 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
51 ms |
5280 KB |
n=50000 |
12 |
Correct |
51 ms |
5664 KB |
n=50000 |
13 |
Correct |
32 ms |
3488 KB |
n=10 |
14 |
Correct |
42 ms |
3232 KB |
n=685 |
15 |
Correct |
39 ms |
3360 KB |
n=623 |
16 |
Correct |
21 ms |
2084 KB |
n=973 |
17 |
Correct |
34 ms |
2596 KB |
n=989 |
18 |
Correct |
16 ms |
1280 KB |
n=563 |
19 |
Correct |
31 ms |
1664 KB |
n=592 |
20 |
Correct |
26 ms |
1644 KB |
n=938 |
21 |
Correct |
22 ms |
1388 KB |
n=747 |
22 |
Correct |
23 ms |
1516 KB |
n=991 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2094 ms |
211464 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Correct |
0 ms |
364 KB |
n=4 |
5 |
Correct |
0 ms |
364 KB |
n=4 |
6 |
Correct |
0 ms |
364 KB |
n=2 |
7 |
Correct |
0 ms |
364 KB |
n=5 |
8 |
Correct |
3 ms |
1004 KB |
n=8 |
9 |
Correct |
10 ms |
1192 KB |
n=14 |
10 |
Correct |
6 ms |
1004 KB |
n=11 |
11 |
Correct |
51 ms |
5280 KB |
n=50000 |
12 |
Correct |
51 ms |
5664 KB |
n=50000 |
13 |
Correct |
32 ms |
3488 KB |
n=10 |
14 |
Correct |
42 ms |
3232 KB |
n=685 |
15 |
Correct |
39 ms |
3360 KB |
n=623 |
16 |
Correct |
21 ms |
2084 KB |
n=973 |
17 |
Correct |
34 ms |
2596 KB |
n=989 |
18 |
Correct |
16 ms |
1280 KB |
n=563 |
19 |
Correct |
31 ms |
1664 KB |
n=592 |
20 |
Correct |
26 ms |
1644 KB |
n=938 |
21 |
Correct |
22 ms |
1388 KB |
n=747 |
22 |
Correct |
23 ms |
1516 KB |
n=991 |
23 |
Execution timed out |
2094 ms |
211464 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |