prompt string | response string |
|---|---|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
int n, s, v[101], i, u[101], j, x, y, poz[101], m[101];
int main() {
std::cin >> n;
for (i = 1; i <= n; i++) {
std::cin >> v[i];
s += v[i];
u[i] = v[i];
}
std::sort(u, u + n + 1);
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
if (u[i] == v[j] && m[j] == 0... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | //package codechef;
import java.util.*;
import java.io.*;
public class CodeChef
{
public static long arr_max(long arr[])
{
long max = 0;
for(int i = 0; i<arr.length; i++)
{
if(arr[i]>max) max = arr[i];
}
return max;
}
public static int gcd(int a,int b... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
s = input()
a = s.split()
for i in range(len(a)):
a[i] = int(a[i])
su = int(sum(a)/int(n/2))
i = 0
while i < len(a):
j = 1
while j < len(a):
if j == i:
j += 1
if j == len(a):
break
if a[i] + a[j] == su:
print(i+1, j+1)
a[i] = 0
a[j] = 0
else:
j += 1
i += 1 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
# coding: utf-8
# In[19]:
n = input()
a = raw_input().split()
for i in range(n):
a[i] = int(a[i])
b = zip(a, range(n))
b.sort()
for i in range(n/2):
print b[i][1] + 1, b[n - 1 - i][1] + 1
# In[ ]:
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=list(map(int,input().split()))
s=2*sum(a)//n
ii=[]
for i in range(n):
if not i in ii:
for j in range(i+1,n):
if not j in ii and a[i]+a[j]==s:
print(i+1,j+1)
ii.append(i)
ii.append(j)
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
nums = list(map(int, input().split()))
for i in range(n):
nums[i] = (nums[i], i+1)
nums.sort()
for i in range(n//2):
print(nums[i][1] , nums[n-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = input()
lis = map(int,raw_input().split())
tot = sum(lis)
each = (tot*2)/n
pos = [[] for i in xrange(200)]
for i in xrange(n):
pos[lis[i]].append(i+1)
count = 0
cur = 1
while(count < n/2):
if each%2 == 0 and cur == each/2:
while(len(pos[cur])):
print pos[cur][-1],
print pos[cur][-2]
pos[cur].pop()
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
m=list(map(int,input().split()))
l=[]
for i in range(n):
l.append([m[i],i])
l.sort()
for i in range(n//2):
print(l[i][1]+1,l[n-i-1][1]+1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | y=int(input())
lst=list(map(int,input().split()))
c=sum(lst)//(y//2)
i=0
mst=[]
while lst.count(0)!=y:
if(lst[i]!=0):
d=c-lst[i]
lst[i]=0
e=lst.index(d)
lst[e]=0
mst.append((i+1,e+1))
i+=1
for i in mst:
print(*i,sep=' ') |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | N=int(input())
l=input().split()
s=sorted([(int(l[i]),i+1) for i in range(N)])
for i in range(N//2):
print(s[i][1],s[-1-i][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Main {
private static Scanner reader = new Scanner(System.in);
public static void main(String[] args) {
byte n=reader.nextByte();
byte m=(byte)(n/2);
byte[]tab=new byte[n];
int compt=0;
for(byte i=0;i<n;i++){
tab[i]=reader.nextByte();
compt+=tab[i];
}
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=[int(x) for x in input().split()]
a2=[int(x) for x in range(1,n+1)]
new_a=list(map(lambda x,y:(x,y),a,a2))
new_a.sort()
for i in range(n//2):
print(new_a[i][1],new_a[n-1-i][1],sep=' ') |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
n = int(input())
a = sorted(enumerate(map(int, input().split())), key=lambda x: x[1])
for idx in range(n//2):
print('{} {}'.format(a[idx][0] + 1, a[-(idx + 1)][0] + 1))
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
import java.util.Scanner;
public class Main
{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int array[] = new int[num];
int temp[] = new int[num];
for (int i = 0; i < num; i++) {
array[i] = sc.nextInt(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | # n = int(input())
# A = list(map(int,input().split()))
# for i in range(n):
# A[i] = (A[i],i+1)
# A.sort()
# # print(A)
# for i in range(n//2):
# print(A[i][1],A[n-i-1][1])
n = int(input())
cards = list(map(lambda x,i: (i,int(x)),input().split(),range(1,n+1)))
# cards = list(map(int,input().split()))
# cards ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
long long a[100001], flag[100001];
vector<pair<long long, long long> > ans;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, sum = 0;
cin >> n;
for (long long i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
sum /= n / 2;
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
ls = list(map(int,input().split()))
sl = ls.copy()
sl.sort()
j=n-1
#print(ls)
#print(sl)
for i in range(int(n/2)):
if ls.index(sl[i]) != -1:
print(ls.index(sl[i])+1,end=' ')
ls[ls.index(sl[i])] = -1
if ls.index(sl[j]) != -1:
print(ls.index(sl[j])+1)
ls[ls.index(s... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class xyz {
public static void main(String[] args)
{
Scanner sc =new Scanner(System.in);
int n=sc.nextInt();
int total=0;
int[]xyz=new int[n];
for (int i = 0; i < xyz.length; i++)
{
xyz[i]=sc.nextInt();
total=total+xyz[i];
}
total=total/(n/2);
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
arr = zip(map(int, raw_input().split()), range(1, n + 1))
arr.sort(key=lambda x:x[0])
for i,j in zip(arr[:n/2], arr[n/2:][::-1]):
print i[1], j[1] |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | /*package whatever //do not write package name here */
import java.io.*;
import java.util.*;
public class GFG {
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
sc.nextLine();
String[] s=sc.nextLine().trim().split("\\ ");
long[] b=new long[a];
int[] dd=new... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.*;
import java.util.Locale;
import java.util.StringTokenizer;
public class Main {
public void solve() throws IOException {
// write your code here
int n = nextInt ();
int a[] = new int[n];
boolean used[] = new boolean[n];
int res = 0;
for (int i = 0; ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, i, j, k, p, t = 0;
map<long long, long long> mp, bp;
map<long long, long long>::iterator it;
vector<pair<long long, long long> > v;
cin >> n;
long long a[n + 1];
for (i = 0; i < n; i++) {
cin >> a[i];
v.push_back(make_pair(a[i... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | numbers = []
n = int(input())
i = 1
for x in input().split():
numbers.append((int(x), i))
i += 1
numbers = sorted(numbers)
for x in range(n//2):
print(numbers[x][1], numbers[n - x - 1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | /**
* Created by hailoc12 on 10/17/2017.
*/
import java.util.Scanner;
import java.util.Arrays;
public class Cards {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] cards = new int[n];
int numPlayer = n / 2;
int sum... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = map(int,raw_input().split())
s = sum(a)
d = s*2/n
for i in xrange(n):
if a[i]!=0:
l = a[i]
a[i] = 0
t = a.index(d-l)
print i+1,t+1
a[t]=0
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Codeforce {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] m = new int[n];
int[] mark = new int[n];
int total = 0;
for (int i = 0; i < n; i++) {
m[i] = sc.n... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, a, sum = 0, b, c = 0, k, s, j;
cin >> a;
int ar[a + 1];
for (i = 1; i <= a; i++) cin >> ar[i];
for (i = 1; i <= a; i++) {
sum = sum + ar[i];
}
c = sum / (a / 2);
for (i = 1; i <= a; i++) {
for (j = i + 1; j <= a; j++) {
if (... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | cardCount = int(input())
cardListStr = input()
cardListStrs = cardListStr.split(' ')
cardList = [int(card) for card in cardListStrs]
cardSum = 0
for card in cardList:
cardSum += card
cardAvg = cardSum/cardCount
playerSum = cardAvg*2
result = {}
for i in range(cardCount):
for j in range(cardCount):
if(i=... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.LinkedList;
import java.util.Scanner;
/**
* Created by Администратор on 14.07.2016.
*/
public class Five {
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int k=0;
LinkedList<Card> cards=new LinkedList<>();
in... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
public class Test
{
public static void main(String []args){
Scanner s = new Scanner(System.in);
int num = s.nextInt();
int []a = new int[num+1];
int sum = 0;
for(int i = 1 ; i < num+1 ; i++) {
a[i] = s.nextInt();
sum = sum + a[i];
}
boolean v[... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int( raw_input() )
x = map( int, raw_input().split() )
maxu = 2 * sum( x ) / n
avail = [1] * n
for i in range( 0, n ):
if avail[i] == 1:
for j in range( 0, n ):
if i != j and avail[j] == 1 and x[i] + x[j] == maxu:
avail[i] = 0
avail[j] = 0
print i+1, j+1
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
arr=input()
arr=arr.split()
#print(arr)
idx=[]
for i in range(n):
idx.append(i+1)
#print(idx)
for i in range(n):
for j in range(n):
if int(arr[i]) > int(arr[j]):
arr[i],arr[j]=arr[j],arr[i]
idx[i],idx[j]=idx[j],idx[i]
for i in range(n//2):
print(str(idx[i])+' '+str(idx[n-i-1]))
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
def give_cards(n, cards):
result = []
cards_copy = cards[:]
for i in range(1, n):
sum = cards_copy[0][1] + cards_copy[i][1]
if cards_copy[0][1] >= cards_copy[i][1]:
result.append([1, i+1])
else:
result.append([i + 1, 1])
cards_copy.pop(0)
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
m = list(map(int, input().split()))
aa = list.copy(m)
aa.sort()
dd = aa[0] + aa[-1]
igr = [n + 1]
for i in range(n):
for j in range(i + 1, n):
for jj in igr:
if m.index(m[i]) != jj and m.index(m[j]) != jj and dd - m[j] == m[i]:
igr.append([i + 1, j + 1])
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int n, a[120], sum, ans;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
ans = sum / (n / 2);
for (int i = 0; i < n; i++) {
if (a[i] != 0) {
for (int j = 0; j < n; j++) {
if (i != j && a[i] + a[j] == ans) ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=list(map(int,input().split()))
t=n//2
b=[]
u,s=0,0
e=sum(a)//t
for i in range(n):
for j in range(i+1,n):
if a[i]+a[j]==e:
if i+1 not in b:
if j+1 not in b:
print(i+1,j+1)
b.append(i+1)
b.append(j+1)
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input());c=[int(i) for i in input().split()];s=sum(c)//(n//2)
for i in range(n):
if c[i]!=0:
b=c[i];c[i]=0;a=c.index(s-b);print(i+1,a+1);c[a]=0 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
void mergesort(int* arr, int n) {
if (n <= 1) return;
int* ptr1 = arr;
int* ptr2 = arr + n / 2;
mergesort(ptr1, n / 2);
mergesort(ptr2, n - n / 2);
int* final = new int[n];
int i = 0;
int j = 0;
bool ifin = false;
bool jfin = false;
for (int k = 0; k <... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0), cout.precision(15);
int n;
cin >> n;
int s = 0;
vector<vector<int> > mp(101);
for (int i = 1; i <= n; i++) {
int ai;
cin >> ai;
mp[ai].push_back(i);
s ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = map(int, raw_input().split())
c = int(sum(a) / (int(n / 2)))
b = [0] * n
for i in range(0, n - 1):
if b[i] is 0:
for j in range(i + 1, n):
if (a[i] + a[j]) == c and b[j] is 0:
if a[i] >= a[j]:
print i + 1, j + 1
else:
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import operator
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for i in range(n): d[i+1] = arr[i]
dn = sorted(d.items(), key=operator.itemgetter(1))
for i in range(n//2): print(dn[i][0], dn[n-i-1][0])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = map(int, raw_input().split())
p = range(1, n + 1)
t = sorted(zip(a,p))
for i in range(n//2):
print str(t[i][1]) + " "+ str(t[-(i+1)][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
sp=input().split()
for i in range(0,len(sp)):
sp[i]=(sp[i],i+1)
sp.sort(key=lambda x:int(x[0]))
for i in range(0,n//2):
print(int(sp[i][1]),int(sp[n-i-1][1])) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | # cf 701 A 800
n = int(input())
A = [*zip(map(int, input().split()), range(1, n + 1))]
A.sort(key=lambda x: x[0])
i, j = 0, len(A) - 1
while i < j:
print(A[i][1], A[j][1])
i += 1
j -= 1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int,input().split()))
z = max(a) + min(a)
for i in range(len(a)):
if a[i]>0:
for j in range(i+1,len(a)):
if a[j] == z-a[i]:
print(i+1,j+1)
a[i] = 0
a[j] = 0
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = raw_input().split()
a = [int(i) for i in a]
pair = sum(a)/(n/2)
for i in range(n):
if a[i]>0:
b = a[i]
a[i] = -10
z = a.index(pair-b)
print str(i+1) + " " + str(z+1)
a[z] = -10
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int, input().split()))
l1 = []
for i in l:
l1.append(i)
l1.sort()
isk = sum(l1) // (n // 2)
b = []
while len(l1) > 0:
x = l1.pop()
y = isk - x
l1.remove(y)
b.append(x)
b.append(y)
d = []
for i in range(n):
for j in range(len(l)):
if b[i] == l[j]:
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
static int count=0,k1,k2,num;
static boolean[][] visited;
static int[][] path , p... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
import java.io.*;
public class CF701A{
private static InputStream stream;
private static PrintWriter pw;
private static byte[] buf = new byte[1024];
private static int curChar;
private static int numChars;
private static SpaceCharFilter filter;
static class Node{
int ind = 0;
int val ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
struct node {
int n;
int c;
};
int main() {
int t;
node card[110];
while (~scanf("%d", &t)) {
for (int i = 1; i <= t; i++) {
scanf("%d", &card[i].n);
card[i].c = i;
}
node tmp;
for (int i = 1; i <= t; i++) {
for (int j = i; j <= t... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
ls = [int(x) for x in input().split()]
somma = int(2*sum(ls)/n)
for i in range(0,n):
for j in range(i+1,n):
bool = 0
if (ls[i] + ls[j]) == somma:
print(str(i+1)+' '+str(j+1))
ls[i] = 0
ls[j] = 0 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
public class Likes {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
n /= 2;
sum /= n;
for (int i = 0; i < 2 * n; i++) {
for (int j = i + 1; j < 2 * n; j++) {
if (a[i] + a[j] == sum) {
cou... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Main701A {
public static void main( String[] args ) {
Scanner scanner = new Scanner( System.in );
int n = scanner.nextInt();
int[] array = new int[n];
int totalSum = 0;
for ( int i = 0; i < n; i++ ) {
int number = scanner.nextInt();
totalSum += number;
ar... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
int main() {
int n, a[100], i, k, j;
float sum, aver;
scanf("%d", &n);
for (i = 0, sum = 0; i < n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
aver = sum / n * 2.0;
for (i = 0; i < n; i++) {
for (j = n - 1; j >= 0; j--) {
if (a[i] + a[j] == aver && i != j) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
temp = input().split()
c0=[(int(temp[i]),i+1) for i in range(len(temp))]
c0.sort()
for i in range(int(n/2)):
print("%d %d" % (c0[i][1], c0[n-i-1][1])) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
b=list(map(int,input().split()))
d=sorted([[b[i], str(i+1)] for i in range(n)])
print(*(d[0+i][1]+' '+d[n-1-i][1] for i in range(n//2)),sep='\n')
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
while (x != 0 && y != 0) {
int r = x;
x = y;
y = r % y;
}
return x + y;
}
bool isprime(int x) {
if (x < 2) return false;
for (int i = 2; i < x; i++) {
if (x % i == 0) {
return false;
}
}
return true;
}
int lcm(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #-------------Program-------------
#----KuzlyaevNikita-Codeforces----
#
n=int(input())
a=list(map(int,input().split()))
d=[]
for i in range(n):
d.append([a[i],i+1])
d.sort(key=lambda x:(x[0]))
for i in range(n//2):
print(d[i][1],d[-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
target = sum(a) // (n // 2)
visited = [False] * n
for i in range(n):
if not visited[i]:
for j in range(i + 1, n):
if not visited[j] and a[i] + a[j] == target:
print(i + 1, j + 1)
visited[i] = True
visited[j] = True
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | //package javaapplication27;
import java.util.Scanner;
public class JavaApplication27 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt(), arr[] = new int[n], sum = 0;
for(int i = 0; i < n; i++){
arr[i] = scan.n... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
b = sum(a) // (n // 2)
for i in range(n):
for j in range(i + 1, n):
if a[i] + a[j] == b:
a[i] = a[j] = 0
print(i + 1, j + 1)
if a[i] == 0:
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | numbers = dict()
n = int(input())
sum = 0
intStr = input()
i = 1
for x in intStr.split():
numbers[i] = int(x)
i += 1
sum += int(x)
forOnePlayer = sum // (n // 2)
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
if (i in numbers and j in numbers
and numbers[i] + numbers[j] == f... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
ar = list(map(int, input().split()))
su = int((sum(ar) / n) * 2)
for i in range(n):
for j in range(i+1,n):
if not ar[i] or not ar[j]:
continue
if ar[i] + ar[j] == su:
print(i + 1, j + 1)
ar[i], ar[j] = 0, 0
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = raw_input().strip().split()
l = []
for i, j in enumerate(a):
l.append((int(j),i+1))
l = sorted(l)
for i in xrange(n/2):
k = l[i]
m = l[n-1-i]
print k[1],m[1]
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
public class Cards{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[][] a = new int[n][2];
for (int i = 0; i < n; i++) {
a[i][0] = in.nextInt();
a[i][1] = i + 1;
}
Arrays.sort(a, (o1, o2) -> (o1[0] - o2[0]));
for (int i = 0... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
lst = [[] for i in range(101)]
s = sum(a)
s = s // (n // 2)
for i in range(n):
lst[a[i]].append(i)
for i in range(1, (s + 1) // 2):
if len(lst[i]) != 0:
for j in range(len(lst[i])):
print(min(lst[i][j], lst[s-i][j]) + 1, max(lst[i][j], lst... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = [int(n) for n in raw_input().split()]
blacklist = []
#cho i chay
for i in range(len(a)):
if blacklist.count(i) != 0:
continue
elif blacklist.count(i) == 0:
for j in range(i+1, len(a)):
if blacklist.count(j) !=0:
continue
elif a[i]+... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main(void) {
cin.sync_with_stdio(0);
int n, a[100], sum = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
int ans = sum * 2 / n;
for (int i = 0; i < n; i++) {
if (a[i] == -1)
continue;
else {
for (int j = ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int maxVec(vector<int> vec) {
sort(vec.begin(), vec.end());
int res = vec.back() + vec.front();
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
vector<int> vec;
cin >> n;
for (int i = 0; i < n; i++) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = input().split()
b = sorted([(int(a[i]), i + 1) for i in range (n)])
for i in range (int(n / 2)):
print (b[i][1], b[-i - 1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Su {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
long arr[]=new long[n];
long s=0;
for(int i=0;i<n;i++) {
arr[i]=sc.nextInt();
s+=arr[i];
}
lon... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n], b[n], i, j;
for (i = 0; i < n; i++) {
cin >> a[i];
b[i] = i + 1;
}
for (i = 0; i < n - 1; i++) {
for (j = 0; j < n - i - 1; j++) {
if (a[j] > a[j + 1]) {
swap(a[j], a[j + 1]);
swap(b[j], b... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int mark[200], id[200], N;
vector<int> A;
bool cmp(const int i, const int j) { return A[i] < A[j]; }
int main() {
cin >> N;
A.resize(N);
int S(0);
for (int i = 0; i < N; i++) cin >> A[i], id[i] = i;
sort(id, id + N, cmp);
for (int i = 0; i < N / 2; i++)
cout... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int n;
int sum;
vector<int> v[111];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
sum += x;
v[x].push_back(i + 1);
}
sum *= 2;
sum /= n;
for (int i = 1; i <= 100; i++) {
while (v[i].size()) {
cout << v[i].back();... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.io.File;
import java.io.PrintWriter;
import java.util.Arrays;
public class a {
static PrintWriter writer;
static Scanner in;
static final int N = 111;
static int n;
static int[] a = new int... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
import java.util.Arrays;
public class C364A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int ii = Integer.parseInt(sc.nextLine());
String[] t = sc.nextLine().split(" ");
int[] list = new int[ii];
int sum = 0;
for(int x=0; x<ii; x++){
list[x... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class cards {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] a; a = new int[n];
int sum=0;
for (int i = 0; i < n; i++) {
int x = scanner.nextInt();
a[i] = x;
sum+=x;
}
int [] x1; x1 = new int [n];
int [] x2; x2 = new i... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class meh {
public static void main(String[] args) throws IOException {
Scanner sc= new Scanner(Sy... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n,b=int(input()),list(map(int,input().split()))
d=sorted([[b[i], str(i+1)] for i in range(n)])
print(*(d[0+i][1]+' '+d[n-1-i][1] for i in range(n//2)),sep='\n')
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | //package March16;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.StringTokenizer;
publi... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | if __name__ == '__main__':
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
pair_sum = s / (n / 2)
mark = [None] * n
for i in range(n - 1):
for j in range(i + 1, n):
if mark[i] == None and a[i] + a[j] == pair_sum and mark[j] == None:
print(i + 1... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | cards = []
n = int(input())
a = list(map(int, input().split()))
s = sum(a)//(n//2)
for person in range(n//2):
firstCard = 0
index1 = 0
index2 = 0
for card in range(n-1, -1, -1):
if a[card] != 0 and firstCard == 0:
firstCard = a[card]
index1 = card+1
a[card] = 0
elif a[card] != 0:
if firstCard + a[... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
spisok=list(map(lambda x: int(x), input().split(' ')))
sr=(2*sum(spisok)//n)
curr=0
while curr<n:
if spisok[curr] !=0:
dpl=curr+1
while dpl<n:
if spisok[curr]+spisok[dpl]==sr:
print(1+curr, 1+dpl)
break
else: dpl+=1
spis... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=[int(i) for i in input().split()]
b=[]
for i in range(n):
b.append([a[i],i+1])
b.sort()
for i in range(n//2):
print(b[i][1],b[n-1-i][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = [int(i) for i in input().split()]
b = [[0, 0]] + sorted(list(zip(a, [int(i) for i in range(1, n+1)])))
for i in range(1, n//2+1):
print(b[i][1], b[n-i+1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int n, k, cur, ans, m;
string ch;
pair<int, int> t[200];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> t[i].first;
t[i].second = i + 1;
}
sort(t, t + n);
for (int i = 0; i < n / 2; i++) {
cout << t[i].second << ' ' << t[n - i - 1].second ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | l = list()
n = input()
i = 1
for a in map(int, raw_input().split()):
l.append((a, i))
i += 1
l.sort()
i, j = 0, n - 1
while i < j:
print l[i][1], l[j][1]
i += 1
j -= 1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=list(map(int,input().split()))
s=(sum(a)/n)*2
for i in range(n):
for j in range (i+1,n):
if a[i]+a[j]==s:
print(i+1,j+1)
a[i]=0
a[j]=0
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int c[100][100];
int main() {
int n, a[105], b[105], l = 0, h;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
b[i] = a[i];
}
sort(b + 1, b + n + 1);
int sum = b[1] + b[n];
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <=... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
line = input().split()
card = [[i + 1,int(line[i])] for i in range(n)]
card.sort(key = lambda x:x[1])
for i in range(n // 2):
print(card[i][0],card[n - i - 1][0])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
i... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author anhnth37
*/
public class A_070... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | l=lambda:map(int,raw_input().split())
n=int(raw_input())
a=l()
pairs=n/2
pairs_value=sum(a)/pairs
used=[0]*n
for i in range(n-1):
if used[i]==1:
continue
for j in range(i+1,n):
if used[j]==0 and a[i]+a[j]==pairs_value:
used[i]=1
used[j]=1
print i+1,j+1
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
cards = [int(i) for i in input().split()]
cards2 = []
for i in cards:
cards2.append(i)
cards2.sort()
for i in range((n//2)):
ans = ""
ans += str(cards.index(cards2[i]) + 1)
cards[cards.index(cards2[i])] = 0
ans += " " + str(cards.index(cards2[n - i - 1]) + 1)
cards[cards.index(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import os
from math import *
n = int(input())
t = []
v = []
s = input().split()
sum = 0
for i in range(n):
t.append(int(s[i]))
sum+=int(s[i])
pair_sum = int(2*sum/n)
se = set()
for i in range(n):
if i not in se:
if i != t.index(pair_sum-t[i]) and t[t.index(pair_sum-t[i])] > 0:
print((i+... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
long long int arr[1000001], arr1[1000];
bool myfn(int i, int j) {
if (arr[i] < arr[j]) return true;
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.clear();
long long int t, n, i, j;
cin >> n;
for (i = 0; i < n; i++) {
cin >> arr[i];
}
fo... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.*;
import java.util.*;
public class Main implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void init() throws FileNotFoundException {
try {
in = new BufferedReader(new FileReader("input.txt"));
out =... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> p1, pair<int, int> p2) { return p1.first < p2.first; }
int main() {
int n;
vector<pair<int, int> > a(120);
cin >> n;
for (int i = 0; i < n; i++) {
int v;
cin >> v;
a[i] = make_pair(v, i + 1);
}
sort(a.begin(), a.begin() + n, c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.