# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
308750 |
2020-10-01T20:41:04 Z |
aZvezda |
Gift (IZhO18_nicegift) |
C++14 |
|
627 ms |
79492 KB |
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(labs(x) >= mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
vector<vector<ll> > ans;
ll n, k;
cin >> n >> k;
priority_queue<pair<ll, ll> > pq;
for(ll i = 0; i < n; i ++) {
ll a;
cin >> a;
if(a != 0) {
pq.push({a, i});
}
}
while(pq.size() >= k) {
vector<pair<ll, ll> > curr;
for(ll i = 0; i < k; i ++) {
curr.push_back(pq.top()); pq.pop();
}
ans.resize(ans.size() + 1);
ans.back().push_back(curr.back().first);
for(auto &it : curr) {
ans.back().push_back(it.second + 1);
it.first -= curr.back().first;
if(it.first > 0) {
pq.push({it});
}
}
}
if(pq.size() != 0) {
cout << -1 << endl;
return 0;
}
cout << ans.size() << endl;
for(auto it : ans) {
for(auto itt : it) {
cout << itt << " ";
}
cout << endl;
}
return 0;
}
Compilation message
nicegift.cpp: In function 'int main()':
nicegift.cpp:28: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 'll' {aka 'long long int'} [-Wsign-compare]
28 | while(pq.size() >= k) {
| ~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n=4 |
2 |
Correct |
1 ms |
384 KB |
n=3 |
3 |
Correct |
1 ms |
384 KB |
n=3 |
4 |
Correct |
1 ms |
384 KB |
n=4 |
5 |
Correct |
1 ms |
384 KB |
n=4 |
6 |
Correct |
1 ms |
384 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n=4 |
2 |
Correct |
1 ms |
384 KB |
n=3 |
3 |
Correct |
1 ms |
384 KB |
n=3 |
4 |
Correct |
1 ms |
384 KB |
n=4 |
5 |
Correct |
1 ms |
384 KB |
n=4 |
6 |
Correct |
1 ms |
384 KB |
n=2 |
7 |
Correct |
1 ms |
384 KB |
n=5 |
8 |
Correct |
1 ms |
384 KB |
n=8 |
9 |
Incorrect |
1 ms |
384 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 |
384 KB |
n=4 |
2 |
Correct |
1 ms |
384 KB |
n=3 |
3 |
Correct |
1 ms |
384 KB |
n=3 |
4 |
Correct |
1 ms |
384 KB |
n=4 |
5 |
Correct |
1 ms |
384 KB |
n=4 |
6 |
Correct |
1 ms |
384 KB |
n=2 |
7 |
Correct |
1 ms |
384 KB |
n=5 |
8 |
Correct |
1 ms |
384 KB |
n=8 |
9 |
Incorrect |
1 ms |
384 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
627 ms |
79492 KB |
n=1000000 |
2 |
Correct |
391 ms |
43456 KB |
n=666666 |
3 |
Correct |
221 ms |
25428 KB |
n=400000 |
4 |
Incorrect |
114 ms |
13400 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 |
384 KB |
n=4 |
2 |
Correct |
1 ms |
384 KB |
n=3 |
3 |
Correct |
1 ms |
384 KB |
n=3 |
4 |
Correct |
1 ms |
384 KB |
n=4 |
5 |
Correct |
1 ms |
384 KB |
n=4 |
6 |
Correct |
1 ms |
384 KB |
n=2 |
7 |
Correct |
1 ms |
384 KB |
n=5 |
8 |
Correct |
1 ms |
384 KB |
n=8 |
9 |
Incorrect |
1 ms |
384 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |