701A codeforces - Cards
Solution in C++
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pii pair<int,int>
int n,sol,acc,cpy;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
int nn[n];
for(int i=0;i<n;i++)
cin>>nn[i],
acc+=nn[i];
acc/=n/2;
for(int i=0;i<n;i++)
{
if(nn[i]==-1 || find(nn,nn+n,acc-nn[i])-nn==-1)continue;
cout<<i+1<<" ";
cpy=nn[i];
nn[i]=-1;
sol=find(nn,nn+n,acc-cpy)-nn;
nn[sol]=-1;
cout<<sol+1<<"\n";
}
return 0;
}
0 التعليقات:
إرسال تعليق