# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
501018 | 2022-01-02T08:00:11 Z | dostigator | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 80480 KB |
// author lox:( #pragma GCC optimize("O3") #pragma GCC target("popcnt") #include <bits/stdc++.h> using namespace std; #define popcnt __builtin_popcount #define all(a) a.begin(),a.end() #define low_b lower_bound #define up_b upper_bound #define vii vector<pair<ll,ll>> #define vll vector<pair<ll,ll>> #define pii pair<ll,ll> #define mii map<ll,ll> #define pll pair<ll,ll> #define mll map<ll,ll> #define vi vector<ll> #define vl vector<ll> #define pb push_back #define endl '\n' #define Y second #define X first typedef long double ld; typedef long long ll; const ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},col=107,N=3e6+777; const ll mod=1e9+7,inf=1e18; void fre_open(){freopen("file.in","r",stdin);freopen("file.out","w",stdout);} ll binpow(ll n,ll k){if(k<0)return 0ll;if(k==0)return 1ll;if(k%2)return (binpow(n,k-1)*n)%mod;ll kk=binpow(n,k/2)%mod;return (kk*kk)%mod;} void solve(){ int n,k,sum=0; cin>>n>>k; int a[n+1]; set<pii>s; for(int i=1; i<=n; ++i){ cin>>a[i]; s.insert({a[i],i}); sum+=a[i]; } if(sum%k) {cout<<"-1\n";return;} cout<<sum/2<<endl; for(int i=1; i<=sum/2; ++i){ pii v=*s.rbegin(); s.erase(v); pii u=*s.rbegin(); s.erase(u); cout<<"1 "<<u.Y<<' '<<v.Y<<endl; u.X--; v.X--; s.insert(v); s.insert(u); } } int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //fre_open ll tt=1; //cin>>tt; while(tt--) solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | n=4 |
2 | Correct | 0 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 204 KB | n=3 |
4 | Correct | 0 ms | 204 KB | n=4 |
5 | Correct | 1 ms | 256 KB | n=4 |
6 | Correct | 0 ms | 204 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | n=4 |
2 | Correct | 0 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 204 KB | n=3 |
4 | Correct | 0 ms | 204 KB | n=4 |
5 | Correct | 1 ms | 256 KB | n=4 |
6 | Correct | 0 ms | 204 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Incorrect | 10 ms | 476 KB | Taken too much stones from the heap |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | n=4 |
2 | Correct | 0 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 204 KB | n=3 |
4 | Correct | 0 ms | 204 KB | n=4 |
5 | Correct | 1 ms | 256 KB | n=4 |
6 | Correct | 0 ms | 204 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Incorrect | 10 ms | 476 KB | Taken too much stones from the heap |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2081 ms | 80480 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | n=4 |
2 | Correct | 0 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 204 KB | n=3 |
4 | Correct | 0 ms | 204 KB | n=4 |
5 | Correct | 1 ms | 256 KB | n=4 |
6 | Correct | 0 ms | 204 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Incorrect | 10 ms | 476 KB | Taken too much stones from the heap |
9 | Halted | 0 ms | 0 KB | - |