prompt
string
response
string
Problem: Lena is a programmer. She got a task to solve at work. There is an empty set of pairs of integers and n queries to process. Each query is one of three types: 1. Add a pair (a, b) to the set. 2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n. 3. For a giv...
#include <bits/stdc++.h> using namespace std; template <typename T> T in() { char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == '-') { ng = true; ch = getchar(); break; } if (ch >= '0' && ch <= '9') break; } while (1) { n = n * 10 + (ch - '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()) s = list(map(int, input().split())) dif = 2 * sum(s) // n t = [] for i in range(n): for j in range(n): if s[i] + s[j] == dif and i not in t and j not in t and i != j: print(i + 1, j + 1) t.append(i) t.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...
# import sys # sys.stdin = open("#input.txt", "r") n = int(input()) ls = list(map(int, input().split())) m = sum(ls) // (n // 2) for i in range(n): if ls[i] == -1: continue for j in range(i+1,n): if ls[i] + ls[j] == m: print(i+1,j+1) ls[i] = ls[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()) a = list(map(int, input().split())) b = sorted(a) for i in range(n//2): s = b[i] t = a.index(s) print(t+1, end=' ') a[t] = -1 e = b[-i-1] r = a.index(e) print(r+1) a[r] = -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.lang.*; import java.io.*; import java.util.*; public class Cards { public static void main(String[] args) throws java.lang.Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(ou...
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 A700 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ar[] = new int[n]; int i; int sum = 0; for(i = 0; i < n; i++) { ar[i] = sc.nextInt(); sum += ar[i]; } int each = (2*sum)/n; int val1, val2, m...
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 = list(map(int, input().split())) each_sum = sum(cards) // (n // 2) for i in range(n): if cards[i] != 0: for j in range(n): if cards[i] + cards[j] == each_sum and i != j: print(i + 1, j + 1) cards[i], cards[j] = 0, 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...
//package codeforces; import java.util.*; public class a5 { public static void main(String args[]){ Scanner in = new Scanner(System.in); int n=in.nextInt(); int a[] = new int[n]; int s=0; for(int i=0;i<n;i++){ a[i]=in.nextInt(); s+=a[i]; } boolean b[]=new boolean[n]; s=(s*2)/n; for(int i=0;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()) x=input() l=x.split(' ') arr=[] for i in range(len(l)): arr.append(int(l[i])) i_j=[(None,None)] for i in range (n): i_j.append((arr[i],i+1)) i_j.remove((None,None)) i_j.sort() for i in range(n//2): print(i_j[i][1],i_j[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(i) for i in input().split()] b=[] for i in range(n): b.append([a[i],i+1]) b=sorted(b) for i in range(int(n/2)): print(b[i][1],b[len(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...
n=int(input()) cards= list(map(int, input().split())) mid = sum(cards)//(n//2) used=[] for i in range(n-1): for j in range(i+1,n): if j not in used and i not in used and cards[i]+cards[j]==mid: print(i+1,j+1) used.append(j) used.append(i) 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()) l=list(map(int,input().split())) l1=l[:] for i in range(n//2): d=min(l1) k=max(l1) print(l.index(d)+1,end=" ") l[l.index(d)]=0 print(l.index(k)+1) l[l.index(k)]=0 p1=l1.index(d) l1=l1[:p1]+l1[p1+1:] p2=l1.index(k) l1=l1[:p2]+l1[p2+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.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * Created by pallavi on 22/7/16. */ public class A699 { public static void main(String[] args) throws IOException { Buffere...
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()] for i in range(n): a[i] = [a[i],i+1] a.sort() for i in range(n//2): print(a[i][1],a[-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()) #n,k= map(int, input().split()) #arr=sorted([i,j for i,j in enumerate(input().split())]) arr=list(map(int, input().split())) ls=[] for i in range(n): ls.append([arr[i],i+1]) ls=sorted(ls) i=0 j=n-1 while i<j: print(ls[i][1] ,ls[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()) mat=list(map(int, input().split())) sat = sorted(mat) for i in range(n//2): a = mat.index(sat[i])+1 mat[mat.index(sat[i])] = -1 b = mat.index(sat[-(i+1)])+1 mat[mat.index(sat[-(i+1)])] = -1 print(a," ",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...
from sys impor...
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()) p = n//2 cards = sorted([(i+1, int(x)) for i,x in enumerate(input().split())],key=lambda x: x[1]) for x in range(p): print (cards[x][0], cards[n-x-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 = enumerate(map(int, raw_input().split()), 1) b = sorted(list(a), key=lambda x:x[1]) c = b[::-1] for i in range(n/2): print b[i][0], c[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())) s=sum(a) for i in range(n): if a[i]==0.4: continue for j in range(i+1,n): if a[i]+a[j]==2*s//n: print(i+1,j+1) a[j]=0.4 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().strip()) ll = list(map(int,input().split())) indeks = [] summ = sum(ll) // (n//2) for i in range(n): if i not in indeks: indeks.append(i) k = summ - ll[i] for j in range(n): if ll[j] == k and j not in indeks: print(i+1,j+1) indeks.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...
import sys from collections import Counter from math import factorial input = sys.stdin output = sys.stdout # input = open('input.txt') def read_int(): return [int(x) for x in input.readline().rstrip().split()] [n] = read_int() mas = read_int() s = sum(mas) s = s * 2 / n used = [False] * n for i in xrange(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; void print(vector<int> v) { cout << "|"; for (int i = 0; i < (int)v.size(); i++) { cout << v[i] << " "; } cout << "|\n"; } int main() { int n; cin >> n; vector<int> a[101]; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; a[v[i]].pu...
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.OutputStream; import java.io.PrintWriter; import java.util.Iterator; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamW...
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.Flushable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.InputMismatchException; public class Codeforces { private static InputReader ir = new InputReader(System.in); private static OutputWriter ow = new OutputWriter(System.out); 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...
a=int(input()) b=list(map(int,input().split())) o=(sum(b)/(a/2)) f=1 v=[] for r in b: l=1 for k in b: if(k+r==o): if(r+k==o): if(f not in v and l not in v and l!=f): v.append(f) v.append(l) break l=l+1 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(raw_input()) a = map(int, raw_input().split()) tbc = sum(a)/(n/2) for i in range(n/2): j = 0 while(a[j] == -1): j += 1 print j + 1, need = tbc - a[j] a[j] = -1 for k in range(j+1, len(a)): if a[k] == need: print k + 1 a[k] = -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 = input() l = map(int, raw_input().split()) m = [] e = sum(l) / (n / 2) for i in range(n): if i in m: continue for j in range(i+1, n): if j in m: continue if l[i] + l[j] == e: print str(i+1) + ' ' +str(j+1) m.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()) a = input().split() x = 0 b = [] for i in range(n): a[i] = int(a[i]) x += a[i] b += [i + 1] x //= n // 2 z = 0 for i in range(n // 2): z = a[0] for j in range(1 , n - 2 * i): if a[j] + z == x: print(b[0] , b[j]) c = j break a = a[1: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 sys a = [] for line in sys.stdin: a.append(str(line)) b=len(a) c=[] d=[] for i in xrange(b): c=map(int,a[i][:-1].split(" ")) d.append(c) e=d[0][0] f=sum(d[1]) for i in range(e): for j in range(e): if d[1][i]+d[1][j]==(f*2)/e: if i==j: pass 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...
n = int(raw_input()) s = map(int,raw_input().split()) x = xrange(1,n+1) #print s a = zip(*sorted(zip(s,x))) #print a[1] for i in xrange(n/2): print a[1][i],a[1][n-1-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 = new int[n]; int *b = new int[n]; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = i; } for (int i = 0; i < n; i++) { for (int j = n - 1; j > i; j--) { if (a[j] < a[j - 1]) { int temp = a[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.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner teclado = new Scanner(System.in); //greedy algorithm int cantidad = teclado.nextInt(); int []cartas = new int[cantidad]; int mayor = Integer.MAX_VALUE; int m...
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...
a=int(input()) b=list(map(int,input().split())) sum=min(b)+max(b) for i in range(len(b)): for j in range(i,len(b)-1): if b[i]+b[j+1]==sum: print(i+1,j+2,sep=' ') b[i],b[j+1]=0,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()) cartas = map(int, raw_input().split()) vis = [True for i in xrange(n)] soma = sum(cartas) cadaUm = soma/(n/2) saida = [] for i in xrange(n): for j in xrange(n): if i != j: if (vis[i] and vis[j]): if (cartas[i] + cartas[j]) == cadaUm: vis[i] = False vis[j] = False saida.ap...
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())) l=[] l.extend(a) l.sort() for i in range(n//2): m=a.index(l[i]) a[m]=0 p=a.index(l[n-i-1]) a[p]=0 print(m+1,p+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) dic = {} for i in range(n): if not (a[i] in dic.keys()): dic[a[i]] = list() dic[a[i]].append(i) for key, val in dic.items(): while len(val) != 0: a = val.pop() b = dic[s - key].pop() print(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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class A { public static void main(String[] args) { // Scanner sc = new Scanner(System.in); Fa...
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 Xgreater { bool operator()(const pair<int, int>& lx, const pair<int, int>& rx) const { return lx.first < rx.first; } }; int main() { int n; cin >> n; vector<pair<int, int> > a; for (int i = 0; i < n; i++) { pair<int, int> temp; cin >> temp.fir...
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(x) for x in input().split()] s = 2*sum(L)//n for i in range(n): if L[i] > 0: print(i+1, end = ' ') p = s-L[i] L[i] = 0 print(L.index(p)+1) L[L.index(p)] = 0 else: continue
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 = [0]*n k = sum(a)/n*2 for j in range(len(a)): for i in range(j+1, len(a)): if a[j]+a[i]==k and b[j]==0 and b[i]==0: print(j+1, i+1) b[j]=1 b[i]=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()) a = [int(i) for i in input().split()] for i in range (n): a[i] = (a[i], i+1) a = sorted (a) for i in range (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...
n = int(int(input())/2) c = (list(map(int, input().split()))) s = sorted(c) cards = [] for e in s: i = c.index(e) c[i] = 0 cards.append(i+1) for res in ((zip(cards[0:n+1],cards[:n-1:-1]))): print(' '.join(map(str, res)))
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())) p = [] s = sum(a) * 2 // n for i in range(n): c = a[i] found = False for j in range(len(p)): if len(p[j]) == 1 and a[p[j][0]] == s - c: p[j].append(i) found = True break if not found: p.append([i]) 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...
import math n = int(input()) q = [int(x) for x in input().split()] avg = (sum(q)*2//n) for i in range(n-1): for j in range(i+1, n): if (q[i] + q[j] == avg): print(i+1, end=' ') print(j+1, end=' ') q[i] = -999 q[j] = -999 print()
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()] a_i=[[a[x],x+1] for x in range(n)] a_i.sort() for b in range(int(n/2)): print(a_i[b][1],a_i[n-b-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...
''' text = list() while True: try: l = raw_input() except EOFError: break else: text.append(l) ''' n = input() l = raw_input().split() s = 0 for i in xrange(n): s += int(l[i]) ss = 2 * s / n r = range(n) rr = range(n) for i in r: q = '' if i in rr: #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...
n = int(raw_input()) a = map(int,raw_input().split(' ')) b = [] for i in range(0,n): b.append([a[i],i]) b.sort() for i in range(0,n/2): print "%d %d" %(b[i][1]+1, b[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...
n=int(input()) a=[int(i) for i in input().split()] k=0 for i in range(n): k+=a[i] k=round(2*k/n) for i in range(n): if(a[i]!=0): print(i+1,end=' ') for j in range(i+1,n): if(a[j]==k-a[i]): print(j+1) 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...
# # 701A. Cards # n = int(input()) cards = list(map(int, raw_input().split())) indices = range(1, n + 1) aux = sorted(zip(cards, indices)) for i in range(n / 2): print aux[i][1], aux[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())) index = {} for idx, card in enumerate(cards): index[card] = index.get(card, []) index[card].insert(0, idx + 1) cards.sort() for i in range(n//2): print('%s %s' % (index[cards[i]].pop(), index[cards[n - i - 1]].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()) a = list(map(int, input().split())) indexes = list(range(n)) indexes.sort(key=a.__getitem__) for i in range(n//2): print(indexes[i]+1, indexes[-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; void FastIO() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cout.precision(15); } int main() { FastIO(); int n, i, j, val = 0, sum = 0; vector<int> a, f; cin >> n; a.resize(n + 5); f.resize(n + 5, 0); for (i = 0; i < n; i++) { cin ...
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, b, s = 0; cin >> n; int a[109]; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } b = 2 * s / n; for (int i = 0; i < n - 1; i++) for (int j = i + 1; j < n; j++) if (a[i] + a[j] == b && a[i] > 0) { cout << 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.math.*; import java.io.*; import java.util.*; /* Jai Shree Ram */ public class JAVA { public static int func(int n) { return (n * (n + 1)) / 2; } public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = ...
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() arr=map(int,raw_input().split(" ")) ind=[] for i in range(1,n+1): ind.append(i) for i in range(n-1): for j in range(n-1-i): if(arr[j]>arr[j+1]): temp=arr[j] arr[j]=arr[j+1] arr[j+1]=temp temp=ind[j] ind[j]=ind[j+1] ind[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...
# coding=utf8 if __name__ == '__main__': n = int(input()) line = str(input()) line = line.split() for i in range(n): line[i] = [int(line[i]), i+1] line.sort(key=lambda x: x[0]) for i in range(n//2): print(str(line[i][1])+' '+str(line[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.InputStreamReader; import java.io.PrintWriter; import java.util.LinkedList; import java.util.StringTokenizer; public class A364 { public static void main(String[] args) throws Exception { FastScanner in = new FastScanner(); PrintWriter pw = 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() arr = map(int, raw_input().split()) _sum = sum(arr) match = _sum / (n/2) _bool = [0] * n #print _sum, match for i in range(n): search = arr[i] #print arr[i] #print _bool for j in range(i+1, n): if(_bool[j] == 0 and _bool[i] == 0): if(search + arr[j] == match): ...
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.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.StringTokenizer; ...
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 di[] = {0, -1, 0, 1, -1, -1, 1, 1}; const int dj[] = {1, 0, -1, 0, 1, -1, -1, 1}; int main() { pair<int, int> vet[200]; int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &vet[i].first); vet[i].second = i + 1; } sort(vet, vet + 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...
lng = int(input()) arr = input().split(' ') arr = [int(i)for i in arr] sor = sorted(arr) index_val = [] for i in sor: index_val.append(arr.index(i)+1) arr[arr.index(i)] = -1 for i in range(int(lng/2)): print(index_val[i], index_val[-(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()) ai = [int(x) for x in input().split(' ')] s = sum(ai) / (n/2) k, ii, c = 0, 0, 0 while c != n: for i, a in enumerate(ai): if a == 0: continue if k == 0: k = a ii = i ai[i] = 0 continue if k + a == s: print(ii+1, i+1) ai[i] = 0 k, ii = 0, 0 c += 2 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; typedef struct list { int da, in; } li; li ar[105]; bool cmp(li a, li b) { return (a.da < b.da); } int main() { int n, i, d; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &d); ar[i].da = d; ar[i].in = i + 1; } sort(ar, ar + n, cmp); for (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...
# i t n o A n=input() v=n N=n/2 x=map(int,raw_input().split()) avg=sum(x)/N for i in range(len(x)): for j in range(v): if all([i+1,j+1])>0 and i!=j: if x[i]+x[j]==avg: print i+1,j+1 x[i]=-1 x[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()) a = list(map(int, input().split())) b = [] for i in range(n): b.append(0) s = 0 for i in range(n): s += a[i] sn = s // (n // 2) j = 0 while (j != n - 1): if (b[j] == 0): b[j] = 1 for k in range(n): if (sn - a[k] == a[j]) and (b[k] == 0): print(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; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const double PI = acos(-1.0); const int MAXN = 105; int n, a[MAXN], sum; bool vis[MAXN]; int main(int argc, char const *argv[]) { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); sum += 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...
from collections import defaultdict def solve(n, c): x = c[:] d = defaultdict(list) for i, v in enumerate(c): d[v].append(i) x.sort() for i in range(n//2): a = d[x[i]].pop() b = d[x[n-1-i]].pop() print(a+1, b+1) def main(): n = int(input()) c = list(map(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 CF701A { public static void main(String args[]){ CF701A o=new CF701A(); Scanner sc=new Scanner(System.in); int n=sc.nextInt(); ArrayList<axe> list=new ArrayList<>(); for (int i = 0; i < n; i++) { int x=sc.nextInt(); axe a; a=o.new axe(); a.val=x; a.place=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...
x=input() c=map(int,raw_input().split()) y=2*sum(c)/x fl=[0]*200 for i in range(x): for j in range(x): if c[i]+c[j]==y and i!=j and fl[i]==0 and fl[j]==0: fl[i],fl[j]=1,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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; public class cf_364_1 { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader reader ...
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 N = 110; pair<int, int> a[N]; vector<pair<int, int> > ans; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i].first); a[i].second = i; } sort(a, a + n); for (int i = 0, j = n - 1; i < j; i++, j--) { ans.pus...
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 = [int(x) for x in input().split(' ')] used = [False] * N for i in range(N // 2): mxV = -1 mxI = -1 mnV = 10000000 mnI = -1 for j in range(N): if used[j]: continue if nums[j] > mxV: mxV = nums[j] mxI = j used[mxI] = True for j in range(N): if used[j]: continue if nums[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 main() { int n; cin >> n; vector<pair<int, int> > store; for (int i = 0; i < n; i++) { int nu; cin >> nu; store.push_back({nu, i + 1}); } sort(store.begin(), store.end()); for (int i = 0; i < n / 2; i++) { cout << store[i].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...
n = int(input()) a = [int(x) for x in input().split()] b = sorted(a) j = -1 for i in range(len(a)//2): k = a.index(b[i])+1 a[a.index(b[i])] = 0 l = a.index(b[j])+1 a[a.index(b[j])] = 0 j-=1 print(k,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...
#include <bits/stdc++.h> using namespace std; template <typename T> T BigMod(T b, T p, T m) { if (p == 0) return 1; if (p % 2 == 0) { T s = BigMod(b, p / 2, m); return ((s % m) * (s % m)) % m; } return ((b % m) * (BigMod(b, p - 1, m) % m)) % m; } template <typename T> T ModInv(T b, T m) { return BigMo...
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()) m = sorted([[int(x), i+1] for i,x in enumerate(input().strip().split())]) for i in range(n//2): print("{0} {1}".format(m[i][1], m[-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 a[105], n, sum = 0; int flag[105]; int main() { memset(flag, 0, sizeof(flag)); cin >> n; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; } sum = sum / (n / 2); for (int i = 1; i <= n; i++) { if (flag[i]) continue; 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...
if __name__ == '__main__': n = int(input()) ar = list(map(int,input().rstrip().split())) a = [] for k in ar: a.append(k) ar.sort() for i in range(n//2): val1 = ar[i] val2 = ar[n-1-i] x = a.index(val1) a[x] = -1 y = a.index(val2) a[y] = -1 print(str(x+1) + ' ' + str(y+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 check(lis, j): for yu in lis: if j == yu: return 0 return 1 n = int(input()) li = list(map(int, input().split())) su = int(sum(li)/(n/2)) lis = [] i = 0 while len(li)>0: j = len(li) while j>i: j = j-1 if li[i] + li[j] == su: ...
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 = sorted(a) while len(b) != 0: print(a.index(b[0]) + 1, end=' ') a[a.index(b[0])] = 101 b.pop(0) print(a.index(b[-1]) + 1) a[a.index(b[-1])] = 101 b.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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class pre422 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new 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()) a = list(map(int, input().split())) v = [(a[i], i + 1) for i in range(n)] v.sort() for i in range(n // 2): print(v[i][1], v[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())) x = max(a) + min(a) used = list() for i in range(n): for j in range(i, n): if j not in used and a[i] + a[j] == x and j != i and i not in used: print(i + 1, j + 1) used.append(j) used.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...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<long long, long long> > v; for (int i = 0; i < n; i++) { pair<long long, long long> temp; cin >> temp.first; temp.second = i + 1; v.push_back(temp); } sort(v.begin(), v.end()); for (int i = 0; i < 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...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,fma") using namespace std; template <typename T> using vc = vector<T>; template <typename T> using uset = unordered_set<T>; template <typename A, typename B> using umap = unordered_map<A, B>; template <typename T> using pq ...
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() xx=x.split( ) s=[] p=[] m=n for i in range(0,n): xx[i]=int(xx[i]) a=xx[:] xx.sort() k=1 for hjdf in range(0,m): if k%2==1: o=[] h=xx[0] for i in range(0,n): if a[i]==h and i not in p: o.append(i) p.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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; public class Main1 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); //BufferedReader br = new Buffered...
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() cards = map(int, raw_input().split(" ")) target = sum(cards)*2/N d = {} for i in range(0, 100): d[i+1] = [] for i in range(N): if len(d[target - cards[i]]) > 0: got = d[target - cards[i]].pop() print got+1, i+1 else: d[cards[i]].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...
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; pair<int, int> p[n]; for (int i = 0; i < n; ++i) { int x; cin >> x; p[i].first = x; p[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.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] elements = new int[n]; int sum = 0; for(int i = 0; i < n; i++) { int value = scan.nextInt(); 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...
def main(): n = int(raw_input()) dig = raw_input().split(" ") mark = [False] * n for i in range(len(dig)): dig[i] = int(dig[i]) s = sum(dig) x = s / (n / 2) arr = [] for i in range(x-1): arr.append([]) for i in range(len(dig)): arr[dig[i] - 1].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...
import sys n = int(input()) arr = list(map(int,input().split())) arr2 = sorted(arr) s = -1 found = 0 indexx = [] for i in range(int(n/2)): for j in range(n): if j+1 not in indexx and arr[j] == arr2[i]: indexx.append(j+1) pos1 = j+1 break for j in range(n): 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...
import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; /** * Created by Siddhartha on 7/24/2016. */ public class Driver { public static void main(String[] args) throws Exception { Scanner input = new Scanner(System.in); int numbers = input.nextInt(); int peopl...
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(i) for i in input().split()] t = (sum(l) * 2) // n if n == 2: print(1, 2) else: for i in range(n): if l[i] != 0: x = l[i] l[i] = 0 m = l.index(t - x) print(i + 1, m + 1) l[m] = 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...
def main(): n = int(input()) a = [(int(x), i + 1) for i, x in enumerate(input().split())] a.sort() for i in range(0, n // 2): print(a[i][1], a[n - i - 1][1]) 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...
n = int(input()) a = list(map(int, input().split())) b = [[a[y], y + 1] for y in range(n)] b.sort() for i in range(n // 2): print(str(b[i][1]) + ' ' + str(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()) sp = list(map(int, input().split())) mid = sum(sp) / (n / 2) for i in range(n): for j in range(i+1,n): 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) print(sp.index(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...
a = int(input()) l=sorted(zip(map(int,input().split()),range(1,a+1))) for i in range(0,a//2): print(l[i][1],l[-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.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class CodeForces { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] grd = new int[2][n / 2]; int[] arr = new int[n]; int sum = 0; for ...