Codeforces Cards
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
#define sf scanf
#define pf printf
typedef map<int , bool>mpbi;
int ar[110];
int main()
{
int n;
mpbi mp;
while(~sf("%d", &n))
{
int i,j, sum=0;
mp.clear();
for(i=1; i<=n; i++)
{
sf("%d", &ar[i]);
sum+=ar[i];
}
sum = sum / (n / 2); //cout << sum;
int k=0;
for(i=1; i<=n; i++)
{
for(j=i+1; j<=n; j++)
{
if(ar[i] + ar[j] == sum)
{
//pf("%d %d\n", i, j);
//break;
if(!mp[i] and !mp[j])
{
mp[i]=true;
mp[j] = true;
pf("%d %d\n", i, j);
}
}
}
}
}
return 0;
}
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
#define sf scanf
#define pf printf
typedef map<int , bool>mpbi;
int ar[110];
int main()
{
int n;
mpbi mp;
while(~sf("%d", &n))
{
int i,j, sum=0;
mp.clear();
for(i=1; i<=n; i++)
{
sf("%d", &ar[i]);
sum+=ar[i];
}
sum = sum / (n / 2); //cout << sum;
int k=0;
for(i=1; i<=n; i++)
{
for(j=i+1; j<=n; j++)
{
if(ar[i] + ar[j] == sum)
{
//pf("%d %d\n", i, j);
//break;
if(!mp[i] and !mp[j])
{
mp[i]=true;
mp[j] = true;
pf("%d %d\n", i, j);
}
}
}
}
}
return 0;
}
Comments
Post a Comment