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...
parents = [-1] def sum_array (arrayname): ans = 0 for nums in arrayname: ans = ans + nums return ans def was (index): for d in range(0, len(parents)): if index == parents[d]: return True break return False n = input() players = n/2 cards = map(int, raw_input()...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 code here n = input() input = map(int, raw_input().split()) sum_ = 0 for i in range(0, n): sum_ += input[i] give = sum_/(n/2) done = {} for lol in range(0, n/2): first = True x = 0 y = 0 for i in range(0, n): if i in done: continue if first: firs...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
# -*- coding: utf-8 -*- n = int(raw_input()) num = map(int, raw_input().split()) s = sum(num)*2/n for i in range(n): if num[i] == -1: continue x = num[i] num[i] = -1 j = num.index(s - x) print i+1, j+1 num[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())) x=sum(a)*2//n for i in range(n): for j in range(n): if a[i]+a[j]==x and i!=j: print(i+1,j+1) a[i]=0 a[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...
#include <bits/stdc++.h> const int maxn = 101; int n, a[maxn], sum; bool vis[maxn]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", a + i); sum += a[i]; } sum /= n >> 1; for (int i = 1; i <= n; ++i) { if (vis[i]) continue; for (int j = i + 1; j <= n; ++j) if (!vi...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 scan = new Scanner(System.in); int n = scan.nextInt(), sum = 0; int[] cards = new int[n]; for(int i = 0 ; i < n ; i++){ cards[i] = scan.nextInt(); sum+=cards[i]; } sum/=(n/2); boolean[] b = new boolean[...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
# JAI SHREE RAM import math; from collections import * import sys; from functools import reduce # sys.setrecursionlimit(10**6) def get_ints(): return map(int, input().strip().split()) def get_list(): return list(get_ints()) def get_string(): return list(input().strip().split()) def printxsp(*...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
__author__ = 'Alexander' import sys n = int(sys.stdin.readline()) kart = list(map(int, sys.stdin.readline().split())) sum = sum(kart) each = int(sum*2/n) for i in range(n): if kart[i] != -1: a = kart[i] kart[i] = -1 j = kart.index(each-a) sys.stdout.write(str(i+1)+' '+str(j+1)+'\n') ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) a=[int(x) for x in input().split()] a_i=[[a[x],x+1] for x in range(n)] a_i.sort() a_i[int(n/2):].sort(reverse=True) 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...
n = input() l = map(int, raw_input().split()) s = sum(l)/(n/2) for i in range(n): if l[i]!=0: t = s-l[i] l[i] = 0 j = l.index(t) l[j] = 0 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; bool ip(long long n) { if (n <= 1) return false; if (n == 2) return true; for (long long i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; } long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } long long lc...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 bisect from collections import defaultdict def ni(): return int(raw_input()) def nis(): return map(int, raw_input().split()) def si(): return raw_input() def sis(): return raw_input().split() def solve(n, a): if n == 2: print '1 2' return pair_sum = min(a) + max(a) ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int,input().split())) b = sorted(a) for i in range(n//2): p = a.index(b[i]) a[p] = -1 q = a.index(b[n-i-1]) a[q] = -1 print(p+1,q+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(" "))) ind=[0]*n k=sum(a)/(n/2) for i in range(0,n-1): for j in range(i+1,n): b=k-a[i] if a[j]==b and ind[i]==0 and ind[j]==0: ind[i]=1 ind[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...
# https://codeforces.com/contest/701/problem/A n = int(input()) cards = map(int, input().split()) vector_list = list() for i, j in enumerate(cards, start=1): vector_list.append((i, j)) vector_list.sort(key= lambda x : x[1]) i, j = 0, n-1 while i <=j: print(vector_list[i][0], vector_list[j][0]) 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 operator as op import re import sys from bisect import bisect, bisect_left, insort, insort_left from collections import Counter, defaultdict, deque from copy import deepcopy from decimal import Decimal from functools import reduce from itertools import ( accumulate, combinations, combinations_with_replacemen...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 a: b.append(i) a.sort() c=[] while len(a)!=0: x=b.index(a[0]) b[b.index(a[0])]=0 y=b.index(a[len(a)-1]) b[b.index(a[len(a) - 1])] = 0 c.append([1+x,1+y]) del(a[0]) del(a[len(a)-1]) for i in range(len(c)): print(c[i][0],c[i...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Codeforces { public static void main(String[] args) { TaskA Solver = new TaskA(); Solver.Solve(); } public static class TaskA { public void Solve()...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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=[int(x) for x in range(n)] for i in range(n-1): for j in range(i+1, n): if (a[i]>=a[j]): a[i], a[j]=a[j], a[i] b[i], b[j]=b[j], b[i] 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()) cards = list(map(int, input().split())) mount = (sum(cards) * 2) // n for i in range(n): curr = cards[i] if curr is None: continue cards[i] = None idx = cards.index(mount - curr) cards[idx] = None print(i + 1, 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...
import java.io.*; import java.util.*; public class A { static int n; static int[] arr; static String str; public static void main(String[] args) throws IOException { Flash f = new Flash(); n = f.ni(); arr = f.arr(n); fn(); } static void fn() ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
q=[] def findIndex(w,dic): index=-1 while(index==-1): for i in dic.keys(): if dic[i]==w and i not in q: index=i q.append(i) break return index input() q=[] s=list(map(int,input().split())) dic={} for i in range(len(s)): dic[i+1]=s[i] w...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 hello { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int [n]; int t=0; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); t+=a[i]; } t=t*2/n; for(int i=0;i<n;i++){ ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#coding:utf-8 def get_input(func=int): return map(func,raw_input().split()) n = get_input()[0] L = get_input() ava = sum(L)*2/n idx = 1 qsc = {} for x in L: if not qsc.has_key(x): qsc[x] = [] qsc[x].append(idx) idx += 1 for x in L: tmp = qsc.get(x,[]) if not tmp: continue pr...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.lang.reflect.Field; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Reader.init(System.in); new Main(); } Main() throws IOException { solve(); } void solve() throws IOException { Pr...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = [1 for i in range(n)] s = sum(a) t = s // (n // 2) for i in range(n): for j in range(n): if i != j and b[i] and b[j] and a[i] + a[j] == t: b[i] = b[j] = 0 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()) 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()) a = [int(_) for _ in input().split()] p , q = sum(a)//(n//2) , sorted(a) for i in range(n): if q[i]+q[n-i-1]==p: if q[i] in a and q[n-i-1] in a: x = a.index(q[i])+1 a[x-1] = -1 print(x,a.index(q[n-i-1])+1) a[a.index(q[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.*; import java.util.*; public class A701 { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); int n = input.nextInt(); int[] as = new int[n]; int sum = 0; for(int i = 0; i<n; i++) sum += as[i] = input.nextInt(); boolean...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt();int s=0;int c=0; int[] a=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); s=s+a[i]; }int t=s/(n/2); Arr...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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().strip()) L= map(int, raw_input().strip().split(" ")) s= sum(L) #print s avg= s*2/ len(L) d= {} for i, num in enumerate(L): if d.get(num): d[num].append(i) else: d[num]= [i,] #print d for i, num in enumerate(L): Li= d[avg-num] if Li and len(Li): print "%d %d" %(i+1, Li[-1]+1) del Li...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())) a=list(enumerate(a)) a.sort(reverse=True,key=lambda x:x[1]) for i in range(n//2): print(a[i][0]+1,a[n-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...
from operator import itemgetter def read_number_line(): return [int(i) for i in input().split()] def read_number(): return int(input()) n = read_number() a = read_number_line() indices_values = enumerate(a, start=1) indices_values = sorted(indices_values, key=itemgetter(1)) for i in range(n // 2): pri...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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().strip().split() tp = sorted([(int(l[i]),i+1) for i in range(n)]) for i in range(n//2): print(tp[i][1],tp[-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()) cards=[int(x) for x in input().split(" ")] pos=[i for i in range(1,n+1)] mini=200 switch=True while switch==True: switch=False for i in range(1,n): if cards[i-1]>cards[i]: temp=cards[i] temp2=pos[i] cards[i]=cards[i-1] pos[i]=pos[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()) card=list(map(int, input().split())) cardflag=[] sum=0 for i in range(0, n): sum+=card[i] cardflag.append([0]) sum=sum/(n/2) for i in range(0, n): if cardflag[i]==[0]: for j in range(i, n): if cardflag[j]==[0]: if i!=j: if card[i]+card[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 cards[110]; bool used[110]; bool allUsed(int N) { for (int i = 0; i < N; i++) if (!used[i]) return false; return true; } bool solve(int i, int N, int target) { if (i >= N && allUsed(N)) return true; if (used[i]) return solve(i + 1, N, target); used[i] = tr...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 arr[n]; float sum, avg; for (int i = 1; i <= n; i++) { cin >> arr[i]; sum += arr[i]; } avg = (sum / n) * 2; for (int i = 1; i <= n; i++) { if (arr[i] != 0) { for (int j = 1; j <= n; j++) { if ((arr[...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.util.HashSet; import java.util.Set; import java.util.StringTokenizer; public class DTask { public static void main(String[] args) throws IOException { MyInputReader in = ne...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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, sum = 0; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } sum /= (n / 2); for (int i = 0; i < n; i++) { for (int j = n - 1; j >= 0; j--) { if (arr[j] + arr[i] == sum) { 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...
n=int(input()) l=list(map(int,input().split())) S=sum(l) p=S//(n//2) for i in range(n) : for j in range(n) : if l[i]+l[j]==p and i!=j and l[i]!=-1 and l[j]!=-1 : print(i+1,j+1) l[i]=-1 l[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; int arr[20002]; int main() { long long a, b, c, m, n, p = 0, q, r, i, j, k, t; vector<int> v; cin >> n; for (i = 1; i <= n; i++) { cin >> arr[i]; p += arr[i]; } if (n == 2) { cout << "1 2" << endl; return 0; } k = p * 2 / n; for (j = 1; j <...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int arr[100]; int main() { int n, sum = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> arr[i]; sum += arr[i]; } int sumPair = sum / (n / 2); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (arr[i] + arr[j] == sumPair && i != j...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
# your code goes here n=int(raw_input()) li=map(int,raw_input().strip().split(" ")) sum=0 for i in li: sum+=i sumsin=sum*2/n ansli=[] for i in range(0,n): for j in range(i+1,n): if li[i]+li[j]==sumsin and i not in ansli and j not in ansli: ansli.append(i) ansli.append(j) for i in range(0,len(ansli),2): 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(raw_input()) summa = 0 from collections import defaultdict dic = defaultdict(list) nums = [int(x) for x in raw_input().split()] for i, val in enumerate(nums): summa += val dic[val].append(i) S = summa / (N / 2) for v in nums: if not dic[v]: continue i1 = dic[v].pop() if dic[S-v]...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
N = int(raw_input()) cards = map(int, raw_input().split()) goal = 2 * sum(cards) / N card_finder = {} card_array_index = {} for i, card in reversed(list(enumerate(cards))): if card not in card_finder: card_finder[card] = [] card_array_index[card] = 0 card_finder[card].append(i) done = [False] * N for i, card...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) sum = 0 for i in a: sum += i sum = sum *2 /n used = [False] * n def find(x): for i in xrange(n): if a[i] == sum - x and used[i] == False: used[i] = True return i for i in xrange(n): if used[i]: continue used[i] = True ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 math import sqrt, gcd, log10, log, ceil, floor def ii(): return int(stdin.readline()) def mi(): return map(int, stdin.readline().split()) def li(): return list(mi()) def si(): return stdin.readline() n=ii()-1 a=li() b=[i for i in range(1, n+2)] a=list(zip(a, b)) a.sort() i=0 while i<n: pr...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 a, b = 0, c, i, j, k, ar[1000], br[1000]; scanf("%d", &a); for (i = 1; i <= a; i++) { scanf("%d", &ar[i]); } for (i = 1; i <= a; i++) { br[i] = ar[i]; } for (i = 1; i <= a; i++) { for (j = i; j < a; j++) { if (ar[i] < ar[j + 1]) { c = ar[...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.Arrays; import java.util.Scanner; public class A15 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int[] array1 = new int[n]; for (int i = 0; i < a.length; i++) { a[i] = sc.nextInt(); array1[i] = 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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Cards { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); int n = Integ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.Comparator; import java.util.List; import java.util.Scanner; public class ProblemA { public static void main(String[] args) { int n; int sum = 0; List<Card> cards = new ArrayList<>(); Scanner sc = new Scanner(System.in); n = sc.nextInt(); 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...
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws FileNotFoundException, IOException { InputStream inputStream = System.in; // InputStream inputStream = new FileInputStream("dijkstra.in"); OutputStream outputStream = 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...
#include <bits/stdc++.h> using namespace std; pair<int, int> a[105]; int main() { ios::sync_with_stdio(0); int n, i, no; cin >> n; for (i = 0; i < n; i++) { cin >> no; a[i].first = no; a[i].second = i + 1; } sort(a, a + n); int k = n - 1; for (i = 0; i < n / 2; i++) { cout << a[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...
import java.io.*; import java.util.*; import java.math.*; import static java.lang.System.out; public class CF701A { public static void main(String[] args) throws IOException { //BufferedReader f = new BufferedReader(new FileReader("/Users/spencersharp/Desktop/input.txt")); BufferedRead...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) vals = [(int(x), i + 1) for i, x in enumerate(input().split())] vals.sort() for i in range(n // 2): print('{} {}'.format(vals[i][1], vals[-(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()); ans=0; a=[(0,0)]*n lis=[] lis=input().split() i=0 while i<len(lis): a[i]=(int(lis[i]),i+1) i+=1 a.sort() i=0 while i<len(a)/2: print(a[i][1],a[n-i-1][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.*; public class prob { public static void main(String[] args) throws Exception { Scanner scan = new Scanner(System.in); int num = scan.nextInt(); int[] cards = new int[num]; int min = 101; int max = 0; for(int i = 0; i < num; i++) { cards[i] = scan.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...
import sys def main(): 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...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) l=sorted((int(x),i+1) for i,x in enumerate(raw_input().split())) 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...
# -*- coding:utf-8 -*- import sys def some_func(): """ """ n = input() n_list = map(int,raw_input().split(' ')) total = sum(n_list)/(n/2) cache_list = [] result_list = [] for i in range(n): if i in cache_list: continue for j in range(i+1,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...
n=int(input()) l=list(map(int,input().split())) ul=[] for i in range(1,n+1): ul.append(i) d=sorted(zip(l,ul)) #print(d) l.sort() for i in range(n//2): print(d[i][1],d[-i-1][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) l=input().split() s=sorted([(int(l[i]),i+1) for i in range(n)]) for i in range(n//2): print(s[i][1],s[-1-i][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; long long int MIN(long long int a, long long int b) { if (a < b) { return a; } return b; } int main() { int n; scanf("%d", &n); int arr[n], total = 0; bool choose[n]; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); choose[i] = false; tota...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 javaapplication22; //package javaapplication22; import java.util.Random; import java.lang.Math; import java.util.*; import java.util.ArrayList; public class JavaApplication22 { public static void main(String[] args) { Scanner in= new Scanner(System.in); int count=0; int n=in.nextInt(), ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = input().split(' ') b = [] for i in range(n): b.append(i) for i in range(n-1): for j in range(n - i - 1): if int(a[j]) > int(a[j + 1]): a[j], a[j + 1] = a[j + 1], a[j] b[j], b[j + 1] = b[j + 1], b[j] for i in range(0, n // 2): print(str(b[i] + 1) + " " + s...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.*; import java.io.*; public class A { static final boolean stdin = true; static final String filename = ""; static FastScanner br; static PrintWriter pw; public static void main(String[] args) throws IOException { if (stdin) { br = new FastScanner(); pw = new PrintWriter(new OutputSt...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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> const int N = 150; int n; int a[N]; void init() { std::cin >> n; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } } void work() { static bool visit[N]; memset(visit, false, sizeof(visit)); int sum = 0; for (int i = 1; i <= n; i++) { sum += a[i]; } for (int i = 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() { ios_base::sync_with_stdio(0); cin.tie(0); ; long long int n, i, sum = 0, j; cin >> n; long long int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } for (i = 0; i < n; i++) { if (a[i] == -1) continue; for (j = 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.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; /** * Built using CHelper...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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[101], sum = 0, used[101] = {0}, n; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; sum += a[i]; } sum /= (n / 2); for (int i = 1; i <= n / 2; ++i) { int cur = sum; 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...
import java.util.*; public class task5{ public static void main(String[] args) { Scanner in = new Scanner (System.in); int n = in.nextInt(); int[] a = new int[n]; int minn = 999, maxx = a[0]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); if (a[i] >= maxx) maxx = a[i]; if (a[i] <= minn) minn ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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, a; cin >> n; vector<pair<int, int> > p; for (int i = 0; i < n; i++) { cin >> a; p.push_back({a, i}); } sort(p.begin(), p.end()); for (int j = 0; j < n / 2; j++) { cout << p[j].second + 1 << " " << p[n - 1 - j].second + 1 << endl...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) lst = [int(x) for x in input().split()] used = [False] * n needed = sum(lst) // (n // 2) answer = [] for i, x in enumerate(lst): if used[i]: continue for j, y in enumerate(lst): if used[j] or i == j: continue if x + y == needed: answer.append((...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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> > a(n); for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i + 1; } sort(a.begin(), a.end()); for (int i = 0; i < n / 2; i++) { cout << a[i].second << ' ' << a[n - 1 - i].second << end...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = 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...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> a[105]; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i + 1; } sort(a, a + n); for (int i = 0; i < n / 2; i++) cout << a[i].second << " " << a[n - i - 1].second << endl; return 0; }
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0, m; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; s += arr[i]; } m = (2 * s) / n; for (int i = 0; i < n; i++) { if (arr[i] == -1) continue; for (int j = i; j < n; j++) { if (arr[i] + arr[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.*; import java.math.*; import java.util.*; public class A { static MyScanner in = new MyScanner(); static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringToke...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 #q=int(input()) q=1 for _ in range(q): n=int(input()) l=list(map(int,input().split())) req=sum(l)//(n//2) for i in range(len(l)-1): for j in range(i+1,len(l)): if l[i]+l[j]==req: print(i+1,j+1) l[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...
import java.util.*; import java.io.*; public class cf701a { public static void main(String[] args) throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); PrintWriter output = new PrintWriter(new BufferedOutputStream(System.out)); boolean used[] = new boolean[113]; 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() { ios_base::sync_with_stdio(0); cin.tie(0); int a[100], n, i, j, b = 0, c, d; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; b = b + a[i]; } b = b / (n / 2); for (i = 0; i < n - 1; i++) { for (j = i + 1; j <= n; j++) { if (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()) s = (sum(a)*2)/n b = [1]*n for i in range(n): r = s-a[i] if (b[i]==1): for j in range(i+1,n): if (b[j]==1 and a[j]==r): print i+1, j+1 b[i] = 0 b[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...
# =================================== # (c) MidAndFeed aka ASilentVoice # =================================== # import math, fractions, collections # =================================== n = int(input()) q = [int(x) for x in input().split()] each = sum(q)//(n//2) for i in range(n-1): for j in range(i+1, n): if q[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('')) cards = [int(c) for c in raw_input('').split(' ')] used = [False for i in cards] players = [() for i in range(n/2)] total = sum(cards) target = total / (n/2) for j in range(n/2): card1 = (i for i,v in enumerate(used) if not v).next() used[card1] = True; card2 = (i for i,v in enumerat...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) li = [int(x) for x in input().split()] ans = [True for x in range(n)] sum = 0 for x in range(n): sum += li[x] sum //= (n // 2) for x in range(n): for y in range(x + 1,n): if li[x] + li[y] == sum and ans[x] and ans[y]: print(x + 1, y + 1) ans[x] = False ans[y] = False
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int[100]; int ind[] = new int[100]; for(int i=0;i<n;i++) { arr[i] = sc.nextInt(); ind[i] = i; } for(int i=0;i<n;i++) { 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 = int(input()) a = [int(i) for i in input().split()] for i in range(n): a[i] = [a[i], i + 1] a.sort() l = 0 r = n - 1 while l < r: print(a[l][1], a[r][1]) l += 1 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...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(make_pair(x, i + 1)); } sort(v.begin(), v.end()); for (int i = 0; i < n / 2; i++) { cout << v[i].second << ' ' << v[n - i - 1].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...
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { int ara[110], mark[100] = {0}, sum = 0; for (int i = 0; i < n; i++) { cin >> ara[i]; sum += ara[i]; } int a = n / 2; int ln = sum / a; for (int i = 0; i < n; i++) { if (mark[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 = input() a = map(int, raw_input().split()) S = 2 * sum(a) / N F = [0] * (N + 1) for i in range(N): for j in range(N): if F[i] == 0 and F[j] == 0 and i != j: if a[i] + a[j] == S: F[i] = 1 F[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...
#include <bits/stdc++.h> void qs(int l, int r, int *VL, int *ID) { int i = l; int j = r; int k = *(VL + (i + j) / 2); int temp = 0; while (i <= j) { while (*(VL + i) < k) i = i + 1; while (*(VL + j) > k) j = j - 1; if (i <= j) { temp = *(VL + i); *(VL + i) = *(VL + j); *(VL + 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(raw_input()) t = sorted( zip( map(int, raw_input().split()), range(1, n+1) ) ) for i in xrange(n/2): print t[i][1], t[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 sys, math n=int(input()) z=list(map(int,input().split())) for i in range(n): z[i]=[z[i],i+1] z.sort() for i in range(n//2): print(z[i][1],z[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 sys cards = int(input()) players = cards // 2 card_values = [int(i) for i in input().split()] avg = sum(card_values)//players used = [False for i in range(cards)] for i in range(cards): if not used[i]: card_value = card_values[i] j = next(j for j in range(i+1, cards) if not used[j] and avg == card_value...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
N = int(input()) line = input().split() cards = [(int(line[i]), i) for i in range(0, N)] cards.sort() for i in range(0, N//2): print(cards[i][1]+1, cards[N-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...
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in)); int x=Integer.parseInt(bufferedReader.readLine()...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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());d=sorted(zip(map(int,input().split()),range(1,n+1))) for i in range(n//2):print(d[i][1],d[-i-1][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.*; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import static java.lang.Math.*; public class Main { static class Node implements Comparable<Node> { int idx; int number; Node(int i, int n) { idx = i; number = n; } @Override public int compareTo...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 def get_ints(): return map(int, sys.stdin.readline().strip().split()) def get_array(): return list(map(int, sys.stdin.readline().strip().split())) def input(): return sys.stdin.readline().strip() n = int(input()) arr=get_array() ma = max(arr) mi = min(arr) s = ma+mi check= [False]*n for i in range(0...