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...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Tanzim Ibn Patowary */ public class Main { public static void main(String[] args) { 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 n, a[105], i, z[105], j; int main(void) { while (cin >> n) { fill(a, a + 105, -1); fill(z, z + 105, -1); for (i = 0; i < n; i++) { cin >> a[i]; z[i] = a[i]; } sort(z, z + n); for (i = 0; i < n; i++) { for (j = 0; j < n; 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...
a = int(input()) n = [int(i) for i in input().split()][:a] r = sum(n) y = a/2 t = r/y for l in range(len(n)): if n[l]>0: for k in range (l+1,len(n)+1): if n[l] + n[k]==t: n[l] = 0 n[k] = 0 print(f"{l+1} {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 = int(input()) l = list(map(int, input().split())) lst = [] for i in range(n): lst.append([i, l[i]]) # print(lst) p_cnt = n // 2 one = sum(l) // p_cnt while lst: f = lst[-1] for i in range(len(lst)): x = lst[i] if x[1] + f[1] == one: s = x print(f[0] + 1, s[0] + 1) lst.pop(i) lst.pop() 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 a[105][2]; int main() { int n, sum = 0, b = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i][0]); sum += a[i][0]; } n /= 2; sum = sum / n; for (int j = 1; j <= n; j++) { for (int i = 1; i <= 2 * n; i++) { if (a[i][1] =...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int,input().split())) each = sum(a)*2//n used = [False for _ in range(n)] for i in range(n): if used[i]: continue for j in range(i+1,n): if used[j]: continue if a[i]+a[j] == each: used[i] = True used[j] = 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...
n=int(input()) a=list(map(int,input().split())) b=[0 for i in range(n)] s=sum(a)//(n//2) j=0 for i in range(n//2): found1=False found2=False hulp=[] j=0 while found1==False: if b[j]==0: found1=True b[j]=1 hulp.append(str(j+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()) lst = list(map(int, input().split())) d = [] for i in range(n): d.append((lst[i], i + 1)) d.sort() for i in range(n // 2): print(d[i][1], d[n - i - 1][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
m=int(input());a=list(map(int,input().split()));k=sorted(range(1,m+1),key=lambda z:a[z-1] );[print(k[i],k[-i-1]) for i in range(0,m//2)]
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) arr=input().split() arr=list(map(int,arr)) s=0 for i in arr: s=s+i s=2*s s=s//n hsh=[] for i in range(n): hsh.append(1) for i in range(n): if hsh[i]==1: for j in range(n): if hsh[j]==1 and i!=j: if (arr[i]+arr[j])==s: print (str(i+1)+" "+str(j+1)) hsh[i]=0 hsh[j]=0 break
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = [(idx, int(val)) for idx, val in enumerate(input().split())] a.sort(key=lambda x: x[1]) for i in range(n // 2): print(a[i][0] + 1, a[n - 1 - i][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...
#include <bits/stdc++.h> using namespace std; pair<int, int> a[113]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i].first; a[i].second = i; } sort(a + 1, a + n + 1); for (int i = 1; i * 2 <= n; ++i) { cout << a[i].second << " " << a[n - i + 1].second << endl; } retu...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())) ##print(" ".join(map(str, res))) n = int(input()) a = list(map(int, input().split())) s = [] for i in range(n): s.append([a[i], i+1]) s.sort() #print(s) for i in range(int(n/2)): print(s[i][1], s[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...
k = int(input()) arr = list(map(int, input().split())) i = 0 rez = sum(arr) / k * 2 zdez = {} for i in range(k): if arr[i] not in zdez: zdez[arr[i]] = [] zdez[arr[i]].append(i + 1) for i in zdez: for j in zdez[i]: print(j, zdez[rez - i].pop())
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) arr = list(map(int, input().split())) total = min(arr) + max(arr) for i in range(len(arr)): for j in range(i, len(arr)): if total == arr[i] + arr[j] and i != j: print(i + 1, j + 1) arr[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...
_ = int(input()) cards = [int(x) for x in input().split()] sum_per_player = 2 * sum(cards) / len(cards) hash_of_cards = {} for index, value in enumerate(cards): if value in hash_of_cards: hash_of_cards[value].append(index) else: hash_of_cards[value] = [index] for k in cards: if hash_of_cards[k]: in...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int, input().split())) s = 0 for i in range(len(a)): s += a[i] s = s // (n // 2) i = 0 while i < n: if a[i] != 0: for j in range(i + 1, n): if a[j] != 0 and a[i] + a[j] == s: print(i + 1, j + 1) a[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()) xa = list(map(int, input().split())) a = [] for i in range(len(xa)): a.append([xa[i], i + 1]) a.sort(key=lambda x: x[0]) for i in range(int(n//2)): print(a[i][1], a[n - i - 1][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
# -*- coding: utf-8 -*- """ Created on Wed Jun 3 07:47:28 2020 @author: Harshal """ 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...
def main(): n = int(input()) x = list(map(int,input().split())) each_sum = sum(x)/(n//2) for i in range(len(x)): for j in range(i+1,len(x)): if x[i] +x[j] == each_sum and x[j] !=0: print(i+1,j+1) x[j] =0 break 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()) x = input().split() for j in range(n): x[j] = int(x[j]) y = [] for i in range (n): y.append ([x[i], i + 1]) y.sort() for k in range (int(n/2)): print (y[k][1], y[n-1-k][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; struct G { int a, b; G(int _a, int _b) { a = _a; b = _b; } }; vector<G> ans; int a[110], chk[110]; int main() { int n, sum = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; } sum *= 2; sum = sum / n; fo...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int a[10000], sum, n; bool p[10000]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= n; i++) sum += a[i]; sum /= n / 2; for (int i = 1; i <= n / 2; i++) { for (int j = 1; j <= n; j++) if (!p[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.*; import java.io.*; public class Card { public static void main (String [] args) throws Exception { BufferedReader buffy = new BufferedReader (new InputStreamReader(System.in)); int numbCards = Integer.parseInt(buffy.readLine()); Hand [] cards = new Hand [numbCards]; //LinkedList <Integer>...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 num, ara[100000], sum = 0; bool check[100000]; scanf("%d", &num); memset(check, 0, sizeof(check)); for (int i = 0; i < num; i++) { scanf("%d", &ara[i]); sum += ara[i]; } if (num == 2) { printf("1 2\n"); return 0; } int temp...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) t=map(int,input().split()) t=list(t) li=[] for i in range(n): li+=[[t[i],i+1]] li.sort() for i in range(n//2): print(li[i][1],li[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...
def main(): n = int(input()) cards = list(map(int, input().split())) total_sum = sum(cards) per_person_sum = int(total_sum*2/n) for i in range(n): if cards[i]!=0: for j in range(i+1,n): if cards[i]+cards[j] ==per_person_sum: 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()) n2 = n//2 arr = [int(x) for x in input().split()] che = [0 for i in range(n)] sum = sum(arr) di = sum//n2 for i in range(n): if(che[i]==0): che[i] = 1 s = str(i+1) k = di - arr[i] for j in range(i+1,n): if(che[j]==0): if(arr[j]==k): ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) ai = list(map(int,input().split())) ai2 = list(range(1,n+1)) for i in range(n): for j in range(i+1,n): if ai[j] > ai[i]: temp = ai[i] ai[i] = ai[j] ai[j] = temp temp = ai2[i] ai2[i] = ai2[j] ai2[j] = temp for i in range...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.IOException; import java.util.InputMismatchException; import java.util.LinkedList; public class Cards { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); IntList[] F = new IntList[101]; for (int i ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=input() a=map(int,raw_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[-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 radixsort(long long a[], long long b[], long long n) { long long temp1, temp2, I, K; long long sor[n], k = 0, i, c[10], j, B[n]; for (K = 0; K < 10; K++) { k++; for (j = 0; j < 10; j++) c[j] = 0; for (i = 0; i < n; i++) { temp1 = a[i]; for...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) args = map(lambda x: [int(x), 0], raw_input().split()) for i in range(n): args[i][1] = i + 1 # args = [[1, 1], [5, 2], [7, 3], [4, 4], [4, 5], [3, 6]] list = sorted(args) for i in range(n / 2): print str(list[i][1]) + ' ' + str(list[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 dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } long long power(unsigned long long a, unsigned ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
cards = int(input()) reach = 0 card = 0 ans = [] ansint = [] cardind = 0 data = list(map(int,input().split())) add = sum(data)/(cards/2) for cardind in range(int(len(data))-1): if data[cardind] == -1: continue card = data[cardind] reach = abs(card - add) ansint.append(data[int(cardind)]) ans...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.*; import java.math.BigInteger; import java.util.*; import java.io.IOException; import java.io.InputStream; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { File file = new File("in.txt"); InputStream inputStream = null; // try ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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() s = list(map(int,input().split())) sum = sum(s) d = int(sum/(len(s)/2)) f = [] for i in range(0, len(s)): if i not in f: f.append(i) for j in range(i+1,len(s)): if d-s[i]==s[j] and j not in f: f.append(j) print(str(i+1)+" "+str(j+1)) ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.lang.reflect.Array; import java.util.*; import javafx.util.Pair; public class Codeforces { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[][] m = new int[n][2]; for (int i = 0; i < n; i++) { m[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()) l=list(map(int,input().split())) t=sorted(l) i=0 j=len(t)-1 while i<len(t)/2: pos1=l.index(t[i]) l[pos1]=-1 pos2=l.index(t[j]) l[pos2]=-1 print(pos1+1,pos2+1) i=i+1 j=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(raw_input()) l = [int(x) for x in raw_input().split()] for i in range(0, n/2): mn = 1e9 mx = -1 imn = 0 imx = 0 for i in range(0, n): a = l[i] if a != -1 and a < mn: mn = a imn = i if a != -1 and (a > mx or (a == mx and i > imx...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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(" "))) hand = min(cards) + max(cards) found = {} pairs = [] for i in range(n): if found.get(i, 0) == 1: continue for j in range(i+1,n): if found.get(j, 0) == 1: continue if cards[i] + cards[j] == hand: found[i] = 1 found[j] = 1 pairs.append((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...
rs,ri,rai=input,lambda:int(input()),lambda:list(map(int, input().split())) n = ri() a = sorted(zip(rai(), range(n))) for i in range(n//2): print(a[i][1]+1, a[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...
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.Objects; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream 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...
#include <bits/stdc++.h> int main() { int n, max, min, imax, imin, equal, aa; while ((scanf("%d", &n)) == 1) { int a[n]; for (int i = 0; i < n; i++) scanf("%d", &a[i]); max = min = a[0]; imin = imax = 0; for (int i = 1; i < n; i++) { if (a[i] >= max) { max = a[i]; imax = 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()) c = list(map(int, input().split())) s = sorted(c) match = 0 l = [] p = n // 2 for i in range(p): n -= 1 a = c.index(s[i]) c[a] = -1 b = c.index(s[n]) c[b] = -1 print(a + 1, " ", b + 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...
#!/usr/bin/env python import sys import os import math n = int(raw_input()) cards = map(int, raw_input().split()) idcards = [(id, card) for id, card in enumerate(cards)] idcards = sorted(idcards, key=lambda x: x[1]) for i in range(n/2): print idcards[i][0]+1, idcards[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...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int[] arr=new int[101]; int n=in.nextInt(); int sum=0; for(int i=0 ; i<n ; i++) { arr[i] = in.nextInt(); sum += arr[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()) val = (sum(a)*2) / n lis = [0 for i in xrange(n)] l1 = [] l2 = [] l1 = [] i = 0 while True: if lis[i]!=1: lis[i] = 1 l1.append(i+1) for j in range(i+1,n): if a[j] == val - a[l1[-1]-1] and lis[j]==0: l2.append(j+1) lis[j] = 1 break else: 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; const int N = 100 + 9; int n, arr[N], tot, tag[N]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> arr[i], tot += arr[i]; tot /= n / 2; for (int i = 1; i <= n; i++) if (!tag[i]) { tag[i] = 1; cout << i << ' '; for (int j = i + 1; j <...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
'''input 6 1 5 7 4 4 3 ''' n = int(input()) c = list(map(int, input().split())) a = 2*sum(c) // n s = [(b, a-b) for b in sorted(c)[:n//2] if a-b in set(c) and b <= a//2] for x, y in s: cx = c.index(x) c[cx] = 0 cy = c.index(y) c[cy] = 0 print(cx + 1,cy + 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() a = [int(i) for i in raw_input().split(' ')] t = (sum(a)/(n/2)) seen = set() k = n i=0 while k>0: if i in seen: i+=1 continue seen.add(i) for j in range(i+1,n): if t-a[i]==a[j] and j not in seen: seen.add(j) ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = [int(x) for x in input().split()] s = sum(a)//(n//2) checked = [] for i in range(n): if i not in checked: for j in range(i+1, n): if a[i] + a[j] == s and j not in checked: print(i+1, j+1) checked.append(i) checked.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...
#include <bits/stdc++.h> using namespace std; struct Int { int num; int index; }; bool sortbynum(Int a, Int b) { return a.num < b.num; } int main() { int n; cin >> n; Int a[n]; int x; for (int i = 0; i < n; i++) { cin >> x; a[i].num = x; a[i].index = i + 1; } sort(a, a + n, sortbynum); f...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) A = list(map(int, input().split())) B = sorted([(A[i], i) for i in range(n)]) for i in range (n // 2): print(B[i][1] + 1, B[-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...
n = input() l = map(int, raw_input().split()) cardSum = sum(l)/(n/2) for i in range(n): for j in range(i+1, len(l)): if l[j] == cardSum - l[i]: 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...
#include <bits/stdc++.h> using namespace std; bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); int n; cin >> n; vector<pair<int, int> > d(n, pair<int, int>(0, 0)); for (int i = 0; i < n; i++) { cin >> d[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(' ')] s = sum(a) / (n / 2) cnt = 0 for i in range(len(a)): for j in range(i + 1, len(a)): if a[i] + a[j] == s and cnt != n / 2: cnt += 1 print(i + 1, j + 1) a[j] = -s 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.Scanner; public class Main{ public static void main(String [] args){ byte i; int p,j=0,k; byte n; Scanner sc=new Scanner(System.in); n=sc.nextByte(); Byte vec[]=new Byte[n]; for(i=0;i<vec.length;i++){ vec[i]=sc.nextByte(); ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
T_ON = 0 DEBUG_ON = 0 MOD = 998244353 def solve(): n = read_int() A = read_ints() B = [] for i, a in enumerate(A): B.append((a, i + 1)) B.sort() for i in range(n // 2): print(B[i][1], B[n-1-i][1]) def main(): T = read_int() if T_ON else 1 for i in range(T): so...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 input = new Scanner(System.in); int n = input.nextInt(); pair arr[] = new pair[n]; int first, second; for (int i = 0; i < n; i++) { first = input.nextInt(); second = i + 1; pair p = new pair(first, 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...
# print ("Input n") n = int(input()) # print ("Input the numbers, separated by spaces") thenums = list(int(x) for x in input().split()) used = list(False for x in range(n)) thesum = sum(thenums) eachsum = thesum // (n//2) for k in range(n//2): # Find first one that is still unused start = 0 while (used[st...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) har = map(int,raw_input().split()) a = sum(har)/(n/2) used = [True]*n #print a i = 0; store = [] for i in xrange(n): ai = har[i] if not used[i]:continue used[i] = False for j in xrange(n): bi = har[j] if i != j: if not used[j]:continue if ai + bi == a: used[j] = False store.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()) z=list(map(int,input().split())) k=sum(z)//(n//2) l=[] vis=[0]*n for i in range(n): for j in range(i+1,n): if(i!=j and z[i]+z[j]==k and vis[i]==0 and vis[j]==0): l.append([i+1,j+1]) vis[i]=1 vis[j]=1 for i in range(n//2): print(*(sorted(l[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 n, prom = 0; cin >> n; int cards[n]; bool used[n]; for (int i = 0; i < n; i++) { cin >> cards[i]; prom += cards[i]; used[i] = false; } prom /= n / 2; for (int i = 0; i < n; i++) { ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { int t; cin >> t; v.push_back(make_pair(t, i + 1)); } sort(v.begin(), v.end()); for (int i = 0; i < n / 2; i++) cout ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) answer = [""] * (n//2) cards = list(map(int, input(" ").split())) for i in range(n//2): a = cards.index(max([x for x in cards if str(x).isnumeric()])) answer[i] += str(a + 1) + " " cards[a] = "g" b = cards.index(min([x for x in cards if str(x).isnumeric()])) answer[i] += str(b + 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()) arr = list(map(int,input().split())) arr2 = sorted(arr,reverse=True) p1=[] p2=[] for i in range(n//2): ind = arr.index(arr2[i]) p1.append(ind+1) arr[ind]=0 arr2.reverse() for i in range(n//2): ind = arr.index(arr2[i]) p2.append(ind+1) arr[ind]=0 for i in range(n//2): print(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...
// http://codeforces.com/problemset/problem/701/A import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Scanner; public class Solution { static class Number { private int index; private int value; public Numb...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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> p[111]; int main() { int n, x; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &x); p[i] = make_pair(x, i); } sort(p + 1, p + n + 1); for (int j = 1; j <= n / 2; j++) { printf("%d %d\n", p[j].second, p[n - j + 1].second); ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
# 701A # θ(n^2) time # θ(n) space __author__ = 'artyom' # SOLUTION def main(): n = read() a = read(3) k = 2 * sum(a) // n b = [False] * n for i in range(n - 1): if not b[i]: for j in range(i + 1, n): if not b[j] and a[i] + a[j] == k: 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 = input().strip().split() for index,item in enumerate(a): a[index] = int(item) line = int(sum(a)/(n/2)) for i in range(n): for j in range(i+1,n): if a[i] + a[j] == line: print(i+1," ",j+1) a[i] = 0 a[j] = 0 elif a[i] == 0: break ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) l=list(map(int,input().split())) s=sum(l) d=s//(n//2) c=0 for i in range(n): if(l[i]>0): m=d-l[i] l[i]=l[i]*(-1) l1=l.index(m) print(i+1,l1+1) l[l1]=l[l1]*(-1) c+=1 if(c==(n//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...
n=int(input()) a=list(map(int,input().split())) b=a[:] b.sort() for i in range(n//2): c=a.index(b[i]) a[c]=-1 d=a.index(b[n-1-i]) a[d]=-1 print(c+1,d+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())) temp = (sum(a)*2)//n visited = [] for i in range(len(a)): for j in range(len(a)): if i==j or j in visited or i in visited: continue if a[i]+a[j]==temp: print(i+1,j+1) visited.append(j) visited.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...
N = int(input()) A = list(map(int, input().split())) sumv = sum(A) // (N // 2) d = {} for i in range(N): if A[i] in d: d[A[i]].append(i) else: d[A[i]] = [i] for i in range(N): left = A[i] right = sumv - left # print("debug", left, right, d[left], d[right]) if len(d[left]) == 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())) b = sum(a)//(n//2) c = sorted(a) d = [0 for i in range(n)] for i in range(n//2): x = b-c[i] for j in range(n): if a[j] == x and d[j] == 0: z = j d[j] = 1 break for j in range(n): if a[j] == c[i] and d[j] == 0: y = j d[j] = 1 break print (z+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 = [int(i) for i in input().split()] for i in range(n//2): #print(l) mn = max(l) an = l.index(mn) for i in range(n): if l[i] < mn and l[i] != -1: mn = l[i] an = i l[an] = -1 mx = max(l) ax = l.index(mx) print(an+1,ax+1) l[ax] = -1 #for i in range(n): # if l[i] != -1 : # print(i+1,en...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a[100005]; bool b[100005] = {0}; long long sum = 0; for (long long i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; } long long k = (sum * 2) / n; long long j = 1; long long l; for (long long i = 1; ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
def sol(n, arr): ar_idx = list() for i in xrange(0, n): ar_idx.append([i+1, arr[i]]) ar_idx.sort(cmp=custom_compare) for i in xrange(0, n/2): print str(ar_idx[i][0]) + " " + str(ar_idx[n-i-1][0]) def custom_compare(ar_idx1, ar_idx2): return ar_idx1[1] - ar_idx2[1] if __name_...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) arr=list(map(int,input().split())) v=sum(arr)/n v=int(v*2) f=[True]*n i=0 for p in range(int(n/2)): while(f[i]==False): i+=1 for j in range(i+1,n): if(arr[i]+arr[j]==v and f[j]==True): break print(i+1,j+1) f[i]=False f[j]=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...
n = int(input()) a = map(int,raw_input().split()) s = sum(a)/(n/2) d = [0]*n i = 0 while(i<n): if d[i]==1: i+=1 continue d[i] = 1 v = s-a[i] j = i+1 while(True): #print j,v if d[j]==0 and a[j]==v: d[j] = 1 break j+=1 print i+1,j+1 i+=1
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
def int_lst_input(): return [int(val) for val in input().split(' ')] def int_input(): return int(input()) def solve(): n = int_input() a = int_lst_input() target = sum(a) // (n // 2) idx_used = set() for i in range(0, n): for j in range(0, n): if ( i 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()) vals = [int(i) for i in input().split()] s = 2*sum(vals)//n for i in range(n): for j in range(i+1,n): if(vals[i] + vals[j] == s): print(i+1,j+1) vals[i] = 0 vals[j] = 0
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) throws IOException { //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] d = new int[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...
s=int(input()) t=input() a=t.split(" ") x=[] for i in a: x.append(int(i)) z=sum(x)//(s//2) for i in range(len(x)): if (x[i]!=-1): new=x[i] x[i]=-1 find=z-new pailam=x.index(find) x[pailam]=-1 print(i+1,pailam+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[1000], n; bool t[1000]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int ans = 0; for (int i = 1; i <= n; i++) ans += a[i]; memset(t, true, sizeof(t)); for (int i = 1; i <= n; i++) if (t[i]) { t[i] = false; 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.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.regex.Pattern; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 n=int(input()) cartes=list(map(int,stdin.readline().split())) indiceCarte=[[] for loop in range(n)] for i in range(n): indiceCarte[i]=[cartes[i],i] indiceCarte.sort() for i in range(n//2): inf=i sup=n-i-1 print(indiceCarte[inf][1]+1,indiceCarte[sup][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())) b = a.copy() b.sort() for i in range(int(n/2)): cc = a.index(b[i])+1 a[a.index(b[i])] = 0 bb = a.index(b[-1])+1 a[a.index(b[-1])] = 0 b.remove(b[-1]) print(cc,bb) # В колоде карт есть n карт (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()) cards = [int(i) for i in input().split()] for j in range(n // 2): print(cards.index(min([j for j in cards if j != 0])) + 1, n - cards[::-1].index(max(cards))) cards[cards.index(min([j for j in cards if j != 0]))] = 0 cards[n - cards[::-1].index(max(cards)) - 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(input().strip()) cards = list(map(int, input().strip().split())) total = sum(cards) pair_value = total//(n//2) p = 0 result = [] for i in range(n//2): while cards[p]<0: p += 1 result.append(p+1) v = cards[p] cards[p] = -1 p2 = cards.index(pair_value-v) result.append(p2+1) car...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.*; //267630EY public class Main701A { static PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; int sum=0; for(int i=0;i<n;i...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) ip=list(map(int,input().split())) ip2=[] for i in range(n): ip2.append((i,ip[i])) ip2=sorted(ip2, key=lambda x:x[1]) for i in range(n//2): print(ip2[i][0]+1,ip2[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...
n = int(input()) a = list(map(int, input().split())) summ = sum(a) // (n // 2) array = [] for i in range(n): for j in range(n): if i != j and a[i] + a[j] == summ and i not in array and j not in array: array.append(i) array.append(j) print(i + 1, j + 1) break
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n, max = 0, min = 100, k, l; cin >> n; int *a = new int[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (max < a[i]) max = a[i]; if (a[i] < min) min = a[i]; } for (int j = 0; j < n / 2; j++) { k = 0; l = 0; for (int i =...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(raw_input()) a = map(int, raw_input().split()) b = a[:] b.sort() for i in range(n/2): print a.index(b[i])+1, a[a.index(b[i])] = -1 print a.index(b[n-i-1])+1 a[a.index(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(raw_input()) #n,k=map(int,raw_input().split()) l=map(int,raw_input().split()) d={} ans=chk=0 chk=sum(l)/(n/2) for a,i in enumerate(l): if i in d: d[i].append(a+1) else: d[i]=[a+1] while 1: if len(d)==0: break for i in d: print d[i].pop(), print d[chk-i].pop(...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
def main(): n = int(input()) nums = [int(x) for x in input().split(' ')] done = [0]*n q = sum(nums) // (n//2) for i, x in enumerate(nums): # print(done) if not done[i]: done[i] = 1 y = q - x for j in range(i+1, n): if nums[j]==y ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = map(int,raw_input().strip().split()) if len(set(a))==1: for i in range(0,n-1,2): print i+1,i+2 s = max(a)+min(a) i = 0 while(len(set(a))!=1): if a[i]!=-1: diff = s-a[i] a[i]=-1 j = a.index(diff) print i+1,j+1 a[j]=-1 i+=1