# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
378647 |
2021-03-17T02:41:23 Z |
wiwiho |
Gift (IZhO18_nicegift) |
C++14 |
|
588 ms |
62560 KB |
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const ll MAX = 1LL << 60;
ostream& operator<<(ostream& o, pll p){
return o << '(' << p.F << ',' << p.S << ')';
}
ll iceil(ll a, ll b){
return (a + b - 1) / b;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
priority_queue<pll> pq;
for(int i = 1; i <= n; i++){
ll a;
cin >> a;
pq.push(mp(a, i));
}
vector<pair<ll, vector<int>>> ans;
while(pq.size() >= k){
vector<pll> t;
for(int i = 0; i < k; i++){
t.eb(pq.top());
pq.pop();
}
ll tmp = t.back().F;
ans.eb(mp(tmp, vector<int>()));
for(pll i : t){
ans.back().S.eb(i.S);
i.F -= tmp;
if(i.F) pq.push(i);
}
}
if(!pq.empty()){
cout << "-1\n";
return 0;
}
cout << ans.size() << "\n";
for(auto& i : ans){
cout << i.F << " ";
printv(i.S, cout);
}
return 0;
}
Compilation message
nicegift.cpp: In function 'int main()':
nicegift.cpp:45:21: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
45 | while(pq.size() >= k){
| ~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
588 ms |
62560 KB |
n=1000000 |
2 |
Correct |
363 ms |
38104 KB |
n=666666 |
3 |
Correct |
200 ms |
22224 KB |
n=400000 |
4 |
Incorrect |
114 ms |
12624 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |