# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
493559 |
2021-12-12T06:01:45 Z |
irmuun |
Gift (IZhO18_nicegift) |
C++17 |
|
2000 ms |
24736 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define PI 3.14159265359
ll n,m,t,p,h,c,d,e,f,i,j,k,r,l,mod=1000000007,mod1=998244353,MAX=1e18,ans;
pair<ll,ll>a[1000001],b;
string s,u;
ll df[101];
vector<pair<ll,ll> >v;
vector<ll>dv[101];
void dfs(ll x){
df[x]=1;
for(ll i=0;i<dv[x].size();i++){
if(df[dv[x][i]]==0){
dfs(dv[x][i]);
}
}
}
ll fastPow(ll a,ll b){
ll d=1;
while(b>0){
if(b%2==1){
d=d*a%mod;
}
b/=2;
a=a*a%mod;
}
return d;
}
int main(){
cin>>n>>k;
ll t=0;
ll mx=0;
for(i=1;i<=n;i++){
cin>>a[i].ff;
t+=a[i].ff;
a[i].ss=i;
mx=max(mx,a[i].ff);
}
if(t%k!=0){
cout<<-1;
return 0;
}
if(k==2){
if(mx>t-a[n].ff){
cout<<-1;
return 0;
}
cout<<t/2<<endl;
sort(a+1,a+n+1);
while(t>0){
cout<<1<<' '<<a[n-1].ss<<' '<<a[n].ss<<endl;
a[n-1].ff--;
a[n].ff--;
t-=2;
sort(a+1,a+n+1);
}
}
}
Compilation message
nicegift.cpp: In function 'void dfs(long long int)':
nicegift.cpp:16:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(ll i=0;i<dv[x].size();i++){
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
208 KB |
n=3 |
3 |
Correct |
0 ms |
208 KB |
n=3 |
4 |
Correct |
1 ms |
208 KB |
n=4 |
5 |
Correct |
0 ms |
208 KB |
n=4 |
6 |
Correct |
1 ms |
308 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
208 KB |
n=3 |
3 |
Correct |
0 ms |
208 KB |
n=3 |
4 |
Correct |
1 ms |
208 KB |
n=4 |
5 |
Correct |
0 ms |
208 KB |
n=4 |
6 |
Correct |
1 ms |
308 KB |
n=2 |
7 |
Correct |
1 ms |
336 KB |
n=5 |
8 |
Incorrect |
47 ms |
492 KB |
Taken too much stones from the heap |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
208 KB |
n=3 |
3 |
Correct |
0 ms |
208 KB |
n=3 |
4 |
Correct |
1 ms |
208 KB |
n=4 |
5 |
Correct |
0 ms |
208 KB |
n=4 |
6 |
Correct |
1 ms |
308 KB |
n=2 |
7 |
Correct |
1 ms |
336 KB |
n=5 |
8 |
Incorrect |
47 ms |
492 KB |
Taken too much stones from the heap |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2005 ms |
24736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
n=4 |
2 |
Correct |
0 ms |
208 KB |
n=3 |
3 |
Correct |
0 ms |
208 KB |
n=3 |
4 |
Correct |
1 ms |
208 KB |
n=4 |
5 |
Correct |
0 ms |
208 KB |
n=4 |
6 |
Correct |
1 ms |
308 KB |
n=2 |
7 |
Correct |
1 ms |
336 KB |
n=5 |
8 |
Incorrect |
47 ms |
492 KB |
Taken too much stones from the heap |
9 |
Halted |
0 ms |
0 KB |
- |