# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
89513 |
2018-12-15T07:27:31 Z |
RAkhshon |
Gift (IZhO18_nicegift) |
C++17 |
|
2000 ms |
88140 KB |
#include<bits/stdc++.h>
#define ll long long
#define fr first
#define se second
using namespace std;
set< pair< ll, ll > > st;
vector< pair<ll,pair< ll, ll> > > ans;
int main(){
ll n, k;
cin>>n>>k;
for( ll i =1 ; i <= n ; i ++ ){
ll x;
cin>>x;
st.insert({x,i});
}
/***
std::pair<ll,ll> x;
x=*st.rbegin();
st.erase(x);
***/
while( st.size()>k-1 ){
ll t = k;
while( t > 0 ){
std::pair< ll , ll > x;
x=*st.rbegin();
st.erase(*st.rbegin());
std::pair< ll , ll > y;
y=*st.rbegin();
st.erase(*st.rbegin());
if( x.fr-1 != 0 ) st.insert({x.fr-1,x.se});
if( y.fr-1 != 0 ) st.insert({y.fr-1,y.se});
ans.push_back({1,{x.se,y.se}});
t-=2;
}
}
if( st.size() < k && st.size()!=0 ){
cout<<-1;
return 0;
}
cout<<ans.size()<<endl;
for( ll i = 0; i < ans.size(); i ++ ){
cout<<ans[i].fr<<' '<<ans[i].se.fr<<' '<<ans[i].se.se<<endl;
}
}
Compilation message
nicegift.cpp: In function 'int main()':
nicegift.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while( st.size()>k-1 ){
~~~~~~~~~^~~~
nicegift.cpp:36:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if( st.size() < k && st.size()!=0 ){
~~~~~~~~~~^~~
nicegift.cpp:41:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for( ll i = 0; i < ans.size(); i ++ ){
~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
380 KB |
n=3 |
3 |
Correct |
2 ms |
456 KB |
n=3 |
4 |
Correct |
2 ms |
500 KB |
n=4 |
5 |
Correct |
2 ms |
552 KB |
n=4 |
6 |
Correct |
3 ms |
552 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
380 KB |
n=3 |
3 |
Correct |
2 ms |
456 KB |
n=3 |
4 |
Correct |
2 ms |
500 KB |
n=4 |
5 |
Correct |
2 ms |
552 KB |
n=4 |
6 |
Correct |
3 ms |
552 KB |
n=2 |
7 |
Correct |
2 ms |
552 KB |
n=5 |
8 |
Correct |
4 ms |
1008 KB |
n=8 |
9 |
Correct |
30 ms |
1116 KB |
n=14 |
10 |
Correct |
20 ms |
1116 KB |
n=11 |
11 |
Correct |
145 ms |
5728 KB |
n=50000 |
12 |
Correct |
150 ms |
5740 KB |
n=50000 |
13 |
Correct |
105 ms |
5740 KB |
n=10 |
14 |
Correct |
94 ms |
5740 KB |
n=685 |
15 |
Correct |
105 ms |
5740 KB |
n=623 |
16 |
Correct |
61 ms |
5740 KB |
n=973 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
380 KB |
n=3 |
3 |
Correct |
2 ms |
456 KB |
n=3 |
4 |
Correct |
2 ms |
500 KB |
n=4 |
5 |
Correct |
2 ms |
552 KB |
n=4 |
6 |
Correct |
3 ms |
552 KB |
n=2 |
7 |
Correct |
2 ms |
552 KB |
n=5 |
8 |
Correct |
4 ms |
1008 KB |
n=8 |
9 |
Correct |
30 ms |
1116 KB |
n=14 |
10 |
Correct |
20 ms |
1116 KB |
n=11 |
11 |
Correct |
145 ms |
5728 KB |
n=50000 |
12 |
Correct |
150 ms |
5740 KB |
n=50000 |
13 |
Correct |
105 ms |
5740 KB |
n=10 |
14 |
Correct |
94 ms |
5740 KB |
n=685 |
15 |
Correct |
105 ms |
5740 KB |
n=623 |
16 |
Correct |
61 ms |
5740 KB |
n=973 |
17 |
Incorrect |
110 ms |
5740 KB |
Taken too much stones from the heap |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2036 ms |
88140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
380 KB |
n=3 |
3 |
Correct |
2 ms |
456 KB |
n=3 |
4 |
Correct |
2 ms |
500 KB |
n=4 |
5 |
Correct |
2 ms |
552 KB |
n=4 |
6 |
Correct |
3 ms |
552 KB |
n=2 |
7 |
Correct |
2 ms |
552 KB |
n=5 |
8 |
Correct |
4 ms |
1008 KB |
n=8 |
9 |
Correct |
30 ms |
1116 KB |
n=14 |
10 |
Correct |
20 ms |
1116 KB |
n=11 |
11 |
Correct |
145 ms |
5728 KB |
n=50000 |
12 |
Correct |
150 ms |
5740 KB |
n=50000 |
13 |
Correct |
105 ms |
5740 KB |
n=10 |
14 |
Correct |
94 ms |
5740 KB |
n=685 |
15 |
Correct |
105 ms |
5740 KB |
n=623 |
16 |
Correct |
61 ms |
5740 KB |
n=973 |
17 |
Incorrect |
110 ms |
5740 KB |
Taken too much stones from the heap |
18 |
Halted |
0 ms |
0 KB |
- |