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...
n = int(input()) mas = [] mas.append(list(map(int, input().split(' ')))) msd1 = [] for i in range(0, n, 1): msd1.append(i+1) mas.append(msd1) #print(mas) for i in range(0,n,1): for j in range(n-i-1): if mas[0][j]> mas[0][j+1]: a1 = mas[0][j+1] a2 = mas[1][j+1] mas[0][j+1] = mas[0][j] ma...
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; vector<pair<int, int>> vec; int n, a; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a; vec.push_back(make_pair(a, i)); } sort(vec.begin(), vec.end()); for (int i = 0; i < vec.size() / 2; i++) cout << vec[i].second + 1 << ' ' << vec[vec.si...
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, raw_input().split())) b = [0] * n c = 2 * sum(a) // n for i in range(n): for j in xrange(i + 1, n): if a[i] + a[j] == c and b[i] + b[j] == 0: b[i] = b[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()) x=[int(w) for w in input().split()] a=n//2 y=sum(x)//a m=[] for i in range(n): for j in range(n): if i!=j and x[i]+x[j]==y and i not in m and j not in m: print(i+1,j+1) m.append(i) m.append(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()) l=input().split() l1=sorted([(int(l[i]),i+1) for i in range(n)]) #print(s) for i in range(n//2): print(l1[i][1],l1[-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...
//package ProgDinamica; import java.util.Scanner; /** * Created by Negro on 24/09/2017. */ public class Cards { public static void main(String[] args) { int pos1,pos2; Scanner entrada = new Scanner(System.in); int arreglo[] = new int[entrada.nextInt()]; int total = 0; bo...
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 = [] for i in range (n): b.append(a[i]) b.sort() b = b[::-1] for i in range(n // 2): print(a.index(b[i]) + 1, end = ' ') a[a.index(b[i])] = 0 print(a.index(b[n - i - 1]) + 1) a[a.index(b[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=input() p=map(int,raw_input().split()) t=(2*sum(p))/n i=0 while i<n: if p[i]>0: w = p[i] p[i] = -1 q = p.index(t-w) p[q] = -1 print i+1, q+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...
#include <bits/stdc++.h> using namespace std; int n; struct Node { int pos, num; } node[105]; bool cmp(Node a, Node b) { return a.num < b.num; } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &node[i].num); node[i].pos = i; } sort(node + 1, node + 1 + n, cmp); for (int 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() arr1 = a.split() arr = [] avg = 0 for i in arr1: arr.append(int(i)) avg += int(i) ppl = n // 2 avg = avg // ppl dicts = {} counts = {} index = 0 for i in arr: index += 1 if i not in dicts: dicts[i] = [] dicts[i].append(index) counts[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()) l = zip(list(map(int, input().split())), [i + 1 for i in range(n)]) l = sorted(l) for i in range(n // 2): print(l[i][1], l[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().strip()) cards = list(map(int, input().strip().split())) total = sum(cards) pair_value = total//(n//2) sorted_cards = [(i,cards[i]) for i in range (len(cards))] sorted_cards.sort(key = lambda tup: tup[1]) # print(sorted_cards) for i in range (n//2): print(sorted_cards[i][0]+1,sorted_cards[-i-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...
n = int(input()) sp = list(map(int, input().split())) mid = sum(sp) / (n / 2) for i in range(n): for j in range(n): if i != j: if sp[i] + sp[j] == mid: I, J = sp[i], sp[j] print(sp.index(I) + 1, end=' ') del sp[i] sp.insert(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 a[55][5], s[110]; int tonghang[55], dem0hang[55], d[110]; int n, ln, nn; int coketqua; int tong; void tim(int i, int j) { int k, x, kt; if (coketqua == 1) { return; } if (j == 3) { if (tong != tonghang[i]) { return; } j = 1; i = 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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static class FastReader ...
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...
from sys import stdin from collections import defaultdict n = int(stdin.readline()) nums = list(map(int, stdin.readline().rstrip().split(' '))) s = 0 locations = defaultdict(list) for i, num in enumerate(nums): locations[num].append(i+1) s += num t = s // (n // 2) v = set() for i, num in enumerate(nums): ...
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(' ')) f=sorted(range(len(x)), key=lambda k: x[k]) t=n//2 last=n-1 for i in range(t): print str(f[i]+1)+' '+str(f[last-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...
from sys import stdin,stdout,setrecursionlimit #setrecursionlimit(2*10**5) def listInput(): return map(long,stdin.readline().split()) def printBS(li): for i in xrange(len(li)-1): stdout.write("%d "%li[i]) stdout.write("%d\n"%li[-1]) n=input() li=listInput() nli=[(li[i],i) for i in xrange(n)] s=sum(li)*2/n nli.sort...
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()) h = int(0) x = int(0) s = set() t = 0 a = list(map(int, input().split())) def acc(x): if x in s: return False else: return True for i in range(len(a)): x += a[i] x = x // (n // 2) while h != n // 2: for i in range(len(a) - 1): for j in range(i + 1, len(a), 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())) r=[] for i in range(n): r.append([a[i],i+1]) r.sort() for i in range(n//2): print(r[i][1],r[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(raw_input()) integers=map(int,raw_input().split(" ")) intdic={} for i in xrange(0,n): intdic[i+1]=integers[i] li=sorted(intdic.iteritems(),key=lambda d:d[1]) for j in xrange(0,n/2): print li[j][0], print li[n-1-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...
t = input() ; n = map(int, raw_input().split()) ; a = sorted(n) for i in range(t/2): b = n.index(a[i])+1 ; n[b-1]=-5 c = n.index(a[t-1-i])+1 ; n[c-1]=-5 print b, c
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 p1 { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] arr = new int[n][2]; int avg = 0; for(int i=0; i<n; i++) { arr[i][0] = in.nextInt(); arr[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()) k=list(map(int,input().split())) s=sum(k) a=s//(n//2) for i in range(n): for j in range(i+1,n): if k[i]+k[j]==a: print(i+1,j+1) k[i]=0 k[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.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; public class Main { public static void main(String[] args) throws IOException { Reader r = new Reader(); r.readLine(); int n = r.r...
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 get_pair(cards, start_index, target_sum,is_used): pair = [start_index] for i in range(start_index + 1, len(cards)): if (cards[i] + cards[start_index] == target_sum) and (is_used[i] == False): pair.append(i) return pair n = int(raw_input()) cards = map(int, raw_input().split()) targe...
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=map(int,input().split()) b=sorted([[x,i+1] for i,x in enumerate(a)]) for i in range(n//2):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...
n=int(input()) a=list(map(int,input().split())) d=[] for i in range(n): d.append((a[i],i+1)) d.sort() for j in range(n//2): print(d[j][1],d[-1-j][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())//2 o=list(map(int,input().split())) a=sorted(range(1,2*n+1),key=lambda i:o[i-1]) print("\n".join("%d %d"%v for v in zip(a[:n],a[-1:n-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.Scanner; public class Cards { public static void main(String[] args) { Scanner s = new Scanner(System.in); int loop = s.nextInt(); int x=loop,sum=0; int arr1[] = new int[x]; for(int i=0; i<x; i++) { arr1[i] = s.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(raw_input()) N=map(int,raw_input().split()) b=max(N)+min(N) a=[0]*100 for i in range(n): if a[i]==-1: continue for j in range(n): if a[j]==-1: continue if i==j: continue if N[i]+N[j]==b: 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...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, i, c, d, sum, e, y; cin >> n; int a[110]; c = 1000; d = 0; for (x = 1; x <= n; x++) { cin >> a[x]; c = min(c, a[x]); d = max(d, a[x]); } sum = c + d; for (i = 1; i <= n; i++) { e = sum - a[i]; for (y = i + 1; y <=...
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 main(): n = int(input()) vals = [(int(v),i) for i, v in enumerate(input().split())] vals.sort() for i in range(n//2): print(vals[i][1]+1, vals[n-i-1][1]+1) if __name__ == "__main__": main()
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 main(): n = int(input()) values = list(int(_) for _ in input().split()) total = int((sum(values)) / (n / 2)) used = [False] * n for i in range(n): if not used[i]: used[i] = True for j in range(n): if (not used[j]) and ((values[i]+values[j])==tot...
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; scanf("%d", &n); int a[n]; int i; int tong = 0; for (i = 0; i < n; i++) { scanf("%d", &a[i]); tong += a[i]; } int da = tong / (n / 2); int j; for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) if (a[i] + a[j] == da && 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...
n = int(raw_input()) a = map(int, raw_input().split()) adict = dict() for i in xrange(n): if a[i] in adict: adict[a[i]].append(i) else: adict[a[i]]=[i] flag = [True for i in xrange(n)] #True means have not considered target = 2*sum(a)/n for i in xrange(n): if flag[i]: j = adict[targe...
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(' '))) s = sum(l) / (n / 2) used_index = [] for i in range(0, len(l) -1 ): for j in range(i + 1, len(l)): if l[i] + l[j] == s and j not in used_index and i not in used_index: print(i + 1, j + 1) used_index.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=input() a=map(int,raw_input().split()) s=sum(a)/(n/2) check=[0]*(n+1) for i in range(n): for j in range(n): if(check[i]== 0 and check[j]==0 and i!=j): if(a[i]+a[j]==s): check[i]=1 check[j]=1 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...
import sys n = int(sys.stdin.readline()) xs = [int(x) for x in sys.stdin.readline().split()] per = sum(xs)*2 // n slots = [[] for i in range(per+1)] for i in range(n): slots[xs[i]].append(i+1) for i in range(1, per+1): while len(slots[i]) > 0: x = slots[i].pop() y = slots[per-i].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...
import copy a = input() n = int(a) a = input().split( ) card = [] for i in a: card.append(int(i)) temp = copy.deepcopy(card); temp.sort(); for i in range(n//2): a = temp[i] b = temp[n-i-1] '''print ("- - %d %d" % (a, b))''' a1 = card.index(a); card[a1] = -1 a2 = card.index(b); card[a2] = -1 print ("%d %d" ...
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 = [] count = 1 i = 0 sc = map(int ,raw_input().strip().split(' ')) a = sorted((sc[i],i+1) for i in range(n)) for i in range(n >> 1): print a[i][1],a[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()) a=[int(x) for x in input().split()] b=sum(a)*2//n for i in range(n): if a[i]!=-100: c=a.index(b-a[i],i+1) print(i+1,c+1) a[i]=-100 a[c]=-100
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...
from operator import itemgetter n = int(input()) l1 = [int(i) for i in input().split()] l2 = [i for i in range(1, n + 1)] l = list(zip(l1, l2)) l.sort(key=itemgetter(0)) for i in range(n//2): print(l[i][1], l[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> int main() { int n, i, j, temp, camp; scanf("%d", &n); int a[n], b[n]; for (i = 0; i < n; i++) { scanf("%d", &a[i]); b[i] = i + 1; } for (i = 0; i < n; i++) { for (j = 0; j < n - i; j++) { if (a[j] > a[j + 1]) { temp = a[j]; a[j] = a[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()) l=(input().split()) for i in range(len(l)): l[i]=int(l[i]) for j in range(n//2): indexerk=0 indexerb=0 k=120 b=0 for i in range(len(l)): if l[i]<k and l[i]!=-1: k=l[i] indexerk=i if l[i]>=b and l[i]!=-1: b=l[i] inde...
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=[int(y) for y in input().split()] x=sum(l)//(n//2) l_copy=[] for i in range(n): l_copy.append(l[i]) visited=[] for i in range(n): visited.append(0) for i in range(n): if visited[i]==0: visited[i]=1 for j in range(n): if l_copy[j]==x-l[i] and i!=j and visited[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.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import org.omg.Messaging.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()) li = map(int, raw_input().split()) li2 =sorted([(li[i],i) for i in range(n)]) n=n/2 for i in range(n): print li2[i][1]+1,li2[-1-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...
# cook your dish here n=int(input()) A=list(map(int,input().split())) A=sorted(range(len(A)), key=lambda k: A[k]) i=0 j=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...
x = int(input()) lst = list(map(int,input().split())) ls1 = sorted(lst) for i in range(len(lst)//2): q1 = lst.index(ls1[i]) lst[q1]="N" q2 = lst.index(ls1[-i-1]) lst[q2]="N" print(q1+1,q2+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())) mx=max(a) lst=[] for i in range(n): ind=a.index(min(a)) lst.append(ind+1) a[ind]=mx+1 for i in range(n//2): print(lst[i],lst[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...
import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; public class Main{ public static void main(String[]args)throws IOException,NumberFormatException{ BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(bf.readLine()); 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...
n = int(input()) x = input() x = x.split() for i in range(len(x)): x[i] = int(x[i]) g = max(x)+min(x) a = [] for i in range(n-1): for j in range(i+1,n): if x[i]+x[j] == g: if i not in a and j not in a: a.append(i) a.append(j) for i in range(0,len(a)-1,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...
import java.util.Scanner; public class TestingApp { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int sum = 0; int[] numbers = new int[n]; for (int i = 0; i<n; i++) { numbers[i] = input.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 = input() inp = input() n = int(n) inp = list(map(int, inp.split())) sum = sum(inp) i_sum = int(2*sum/n) n_pl = int(n/2) c_taken = [] c1_ind = 0 for i in range(n_pl): while c1_ind in c_taken: c1_ind += 1 c_taken.append(c1_ind) c1 = inp[c1_ind] c2 = i_sum - c1 c2_ind = 0 while (c2_ind in c_taken or inp[c2...
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() { vector<pair<int, int> > g; int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int a; cin >> a; g.push_back(make_pair(a, i + 1)); } sort(g.begin(), g.end()); int k = g.size() - 1; for (int i = 0; i < n / 2; i++) { cout << g[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 operator n=int(raw_input()) s=map(int,raw_input().split()) su=sum(s) p=list() for i in range(n): # su+=s[i] p.append((s[i],i+1)) p.sort(key=operator.itemgetter(0)) # print su # print p for i in range(n/2): print p[i][1],p[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...
import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class A { public static void main(String[] args) { A a = new A(); Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); List<Integer> values...
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()) card = list(map(int, input().split())) sum = 0 for i in range(len(card)): sum += card[i] per = sum * 2 // n used = [False for i in range(len(card))] for i in range(n // 2): ans = "" num = 0 for j in range(len(card)): if(used[j] == False): ans += str(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())) 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])
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...
from sys import stdin import math n = int(stdin.readline()) a = map(int,stdin.readline().split()) b = [] for i in xrange(1,n+1): b.append((a[i-1],i)) b.sort() x = n/4 c = [] d = [] for i in xrange(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...
#include <bits/stdc++.h> int main() { unsigned short n; unsigned short pl; unsigned short s; unsigned short i; unsigned short a[100]; unsigned short d[100]; unsigned short sp; unsigned short j; unsigned short ar; unsigned short k; unsigned short c[50][2]; if (scanf("%hu", &n) != 1) return -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 Tester { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] val=new int[n]; int[] rem=new int[n]; int sum=0; for(int i=0;i<n;i++) { val[i]=sc.nextInt(); rem[i]=val[i]; sum=sum+val[i]; } int dev=(sum)/(n/2); 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()) cards = [int(x) for x in input().split()] average = int(sum(cards)/(n/2)) for i in range (0, n): if cards[i] != 0: print(i + 1, end=" ") for j in range (i + 1, n): if cards[j] == average - cards[i]: print(j + 1) cards[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 sys """ n Cards Even unordered map """ def main(): cards = int(sys.stdin.readline()) values = [ (int(x),i) for i, x in enumerate(sys.stdin.readline().split(),1)] values.sort() lo = 0 hi = len(values) - 1 while lo < hi: print( str(values[lo][1])+' '+str(values[hi][1])) l...
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 math n = int(input()) a = list(map(int,input().split())) su = sum(a)/(n//2) for i in range(n): if a[i]!=-1: t = a[i] a[i] = -1 idx = a.index(su-t) print("{0} {1}".format((i+1),idx+1)) a[idx] = -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; const int maks = 100; pair<int, int> a[maks + 5]; int main() { int n; int temp; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &temp); a[i] = make_pair(temp, i + 1); } sort(a, a + n); int idx = n - 1; for (int i = 0; i < n / 2; 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() { int n; cin >> n; int a; map<int, int> m; int arr[n], sum = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } sum /= n / 2; for (int i = 0; i < n; i++) { if (arr[i] > 0) { int ans1, ans2; for (int j = 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 = input() A = map(int, raw_input().split()) A = zip(A, range(1,n+1)) A = sorted(A) for i in xrange(n/2): print A[i][1],A[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...
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.Scanner; import java.util.StringTokenizer; public class A implements Runnable { static String Y = "YES", N = "NO"; static long...
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()) cards = map(int, raw_input().split()) s = sum(cards)*2/n pairs = [] f = 0 for i, c in enumerate(cards, start=1): for j, (pi, np) in enumerate(pairs): if np + c == s: print '{} {}'.format(i, pi) del pairs[j] break else: pairs.append((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()); l = list( map(int , input().split())); a = sorted([[l[i] ,i +1] for i in range(n)]) for i in range(n//2): print(a[i][1] , a[-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()) l=list(map(int,input().split())) a=[] for q in range(n): a.append([l[q],q]) a.sort() for q in range(n//2): print(a[q][1]+1,a[n-q-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...
import java.util.Arrays; import java.util.Scanner; public class Cards { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = Integer.parseInt(in.next()); ...
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())) l_sum = sum(l) p_sum = 2*l_sum//n d = [None]*101 for i in range(n): c_diff = p_sum-l[i] if d[c_diff] == None or len(d[c_diff]) == 0: if d[l[i]] == None: d[l[i]] = [i] else: d[l[i]].append(i) else: idx = d[c_...
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.awt.Point; import java.awt.geom.*; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.util.*; public class Main { static class Par implements Comparable<Par> { public int Value; public int Pos; 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...
#include <bits/stdc++.h> using namespace std; int n; vector<pair<int, int> > v; int main() { cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; v.push_back(make_pair(a, i)); } sort(v.begin(), v.end()); int i = 0; n--; for (; i < n; i++, n--) cout << v[i].second + 1 << ' ' << v[n].sec...
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.InputStreamReader; import java.io.StreamTokenizer; import java.util.Scanner; public class P701_A { private static StreamTokenizer inputReader = new StreamTokenizer( new BufferedReader(new InputStreamReader(System.in))); private static Scanner scaner = 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...
# import sys # import time # sys.stdin=open("utest.in","r") # sys.stdout=open("utest.out","w") n=int(input()) p=list(map(int,input().split())) s=sum(p)//(n//2) w=[] for i in range(n): if p[i]!=0: for j in range(i+1,n): if p[i]+p[j]==s: w.append((i+1,j+1)) p[j]=0 break if len(w)==n//2: break for...
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()] g = 0 for i in c: g += i g = g // (n//2) for i in range(n): for j in range(i+1, n): if c[i] + c[j] == g: print(i+1, j+1) c[i] = -1 c[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 = list(map(int, input().split())) avg = sum(arr)/n x = [f-avg for f in arr] c = n//2 i = 0 while c > 0: if x[i] != '#': print(i+1, x.index(-x[i], i+1)+1) x[x.index(-x[i],i+1)] = '#' c -= 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; /* * 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 Kevin */ public class ProblemA364 { public static void main(String[] args){ ...
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 gcd(long long a, long long b) { while (a && b) a > b ? a %= b : b %= a; return a + b; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } int main() { int n; cin >> n; int i, j, sum = 0, in; int a[n]; for (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 ()) s=[[int(z),0] for z in input().split()] for i in range(n): s[i][1]=i+1 s.sort() for i in range(n//2): print(s[i][1],s[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; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; cin >> n; long long arr[n]; for (long long i = 0; i < n; i++) { cin >> arr[i]; } long long k = n / 2; long long s = 0; for (long long i = 0; i < n; 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...
import sys stream = sys.stdin n = int(stream.readline().strip()) l = stream.readline().split() l = [int(li) for li in l] ss = sum(l) pp = 2*ss/n ass = [0]*n pas = [] for i in range(n): if ass[i]: continue # find slot pas.append([i]) ass[i] = 1 for j in range(n): if i!=j and ass...
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...
lista=[] lists=[] a=int(input()) b=input().split(' ') contador=0 total=0 for i in b: i=int(i) lista.append(i) lists.append(i) for j in range(0,a): total+=lista[j] total=total//(a//2) formula=0 for k in range(0,len(lista)): z=lista[k] for l in range(k+1,len(lista)): r=lista[l] ...
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(int(i)) for i in input().split()] b = a[:] x = [] while len(b) != 0: x.append(max(b)) b.remove(max(b)) x.append(min(b)) b.remove(min(b)) for i in range(0, len(x), 2): print(a.index(x[i]) + 1, end=' ') a[a.index(x[i])] = 0 print(a.index(x[i + 1]) + 1) a[a.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 java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(...
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 I(): return map(int, input().split()) n = int(input()) a = list(I()) t = [] for i in range(n): t.append([a[i], i]) x = 2*sum(t[i][0] for i in range(n))//n for i in range(n//2): for ii in range(i+1, n): if t[i][0]+t[ii][0] == x: print(t[i][1]+1, t[ii][1]+1) t.pop(ii) ...
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()) card_num=[int(x) for x in input().split()] sumofcards=sum(card_num) avg=sumofcards/n*2 for i in range(n): if card_num[i]!=-1: for j in range(n): if card_num[i]+card_num[j]==avg and i!=j and card_num[i]!=-1 and card_num[j]!=-1: print("{} {}".format(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()) l = list(map(int, input().split())) d = [] for i in range(n): d.append([l[i], i + 1]) d.sort() for i in range(n // 2): print(d[i][1], d[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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; public class Solution implements Run...
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 sys # sys.stdin=open("input.in","r") # sys.stdout=open("output.out","w") N=int(input()) L=list(map(int,input().split())) y=sum(L) y=int(y/(N/2)) for i in range(N): for j in range(i+1,N): if(L[i]+L[j]==y): L[i]=-10000 L[j]=-10000 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...
#include <bits/stdc++.h> using namespace std; struct f { int s; int num; } a[105]; bool cmp(f x, f y) { return x.s < y.s; } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i].s); a[i].num = i + 1; } sort(a, a + n, cmp); for (int i = 0; i < n / 2; i++) { prin...
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 sys import operator file = sys.stdin cnt = 0 for line in file: if not cnt: n = int(line) else: a = [int(i) for i in line.split()] cnt+=1 sum = 0 x = {} for i in range(n): sum+=a[i] x[i+1]=a[i] sorted_x = sorted(x.items(), key=operator.it...
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())) a = [] for i in range(n): a.append([l[i] , i+1]) a.sort() #print(a) for i in range(n//2): print(a[i][1] , a[-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.io.*; import java.util.*; public class tmp1 { public static InputReader in; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); public static void main(String[] args) { in = new InputReader(System.in); out = new PrintWriter(System.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...
n = input() a = list(map(int, input().split(' '))) b = [] for i in range(len(a)): b.append([a[i], i]) b.sort(key=lambda x: x[0]) for i in range(int(len(a) / 2)): print( "%s %s" %(b[i][1] + 1, b[len(b) - 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...
n=int(input()) l=list(map(int,input().split())) t=int(sum(l)/(n/2)) w=[] for i in range(n): for j in range(i+1,len(l)): if i not in w: if j not in w: if l[i]+l[j]==t: w.append(i) w.append(j) print(i+1,end=' ') print(j+1)