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...
a = int(input()) list1 = list(map(int, input().split())) m=(max(list1))+(min(list1)) for i in range(len(list1)): for j in range(len(list1)): if list1[i]+list1[j]==m and i!=j: print(i+1,j+1) list1[i]=102 list1[j]=102
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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(s) for s in input().split(' ')] taken = [] for i in range(n): if i + 1 not in taken: for j in range(i + 1, n): if j + 1 not in taken and a[i] + a[j] == 2 * sum(a) // n: taken.append(i + 1) taken.append(j + 1) break for k 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()) p=raw_input() a=p.split() a=[int(i) for i in a] s=sum(a)/(n/2) for i in range(0,n): if a[i]!=0: t=a[i] a[i]=0 k=a.index(s-t) print str(i+1)+' '+str(k+1) a[k]=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 NewMain12 { public static void main(String[] args) { FastScanner s = new FastScanner(); int x = s.nextInt(); int[] ar = new int[x]; card[] hm = new card[x]; for (int i = 0; i < x; i++) { card q = new 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()) ent = map(int,raw_input().split()) media = sum(ent)/(n/2) indicesAcessados = [0]*n mapa = {} for i in range(n): j = i+1 if indicesAcessados[i] != 1: soma = ent[i] while j < n: if indicesAcessados[j] == 1: j += 1 elif soma + ent[j] == media: indicesAcessados[j] = 1 ma...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; struct node { int num, id; } a[110]; int cmp(node a, node b) { return a.num < b.num; } int main() { int n, i, ave, sum; while (scanf("%d", &n) != EOF) { for (i = 0; i < n; ++i) { scanf("%d", &a[i].num); a[i].id = i + 1; } sort(a, a + n, cmp); ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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; /** * Created by Timur on 04.11.2016. */ public class _701A { public static void main(String args[]){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[] = new int[n]; int sorted[] = new int[n]; boolean flag...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = [0] + [int(_) for _ in input().split()] total_points = sum(cards) player_points = total_points // (n // 2) marked = [False] * (n + 1) count = 0 for i in range(1, n): if marked[i]: continue for j in range(i + 1, n + 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 static java.lang.System.in; import java.io.IOException; public class A364 { public static byte[] buffer = new byte[8192]; static int offset = 0; static int bufferSize = 0; public static void main(String[] args) throws IOException { int n = readInt(); int arr[] = new int[n]; int sum =0; 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()) arr=[int(x) for x in input().split()] sum=sum(arr) sum1=sum//(n//2) k=1000 for i in range(0,len(arr)-1,1): if arr[i]>100: continue for j in range(i+1,len(arr),1): if arr[i]+arr[j]==sum1: if (i+1)%2==0 and (j+1)%2==0: print(j+1,i+1) 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...
n = int(input()) a = list(map(int,input().split())) x = sum(a) z = [] r = int((x)/int(n/2)) if n == 2: print(1,2) else: for i in range(len(a)): if i in z: continue for j in range(i+1,len(a)): if j in z: continue if a[j] == r - a[i]: z.append(i) z.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...
n = int(input()) lt = [int(_) for _ in input().split()] av = sum(lt) // (n // 2) def find(val): for i in range(n): if lt[i] == -1: continue if lt[i] == val: return i return -1 for i in range(n): if lt[i] == -1: continue p = av - lt[i] lt[i] = -1 pi = find(p) print(str(i + 1) + " " + str(pi + 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, i, x, j; cin >> n; pair<int, int> a[n]; for (i = 0; i < n; i++) { cin >> x; a[i] = make_pair(x, i + 1); } sort(a, a + n); for (i = 0, j = n - 1; i < n / 2; i++, j--) cout << a[i].second << " " << a[j].second << "\n"; 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...
n = int(input()) a = list(map(int, input().split())) b = max(a) + min(a) for i in range(n): for j in range(n): if a[i] + a[j] == b and i != j: print(i + 1, j + 1) a.remove(a[i]) a.insert(i, 0) a.remove(a[j]) a.insert(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...
### codeforces round #364 (div 2) n = int(input()) nums = [int(i) for i in input().split()] summa = sum(nums)*2 // n for pos, val in enumerate(nums): if val == 0: continue nums[pos] = 0 matching = nums.index(summa-val) nums[matching] = 0 print(pos+1, matching+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())) s = sorted([(int(cards[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...
n=int(raw_input()) c=map(int,raw_input().split()) k=2*sum(c)/n d=[] for i in xrange(n): for j in xrange(n): if c[i]+c[j]==k and i!=j and i not in d and j not in d: d.append(i) d.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; const long double PI = 3.141592653589793238462643383279502884L; const long double E = 2.718281828459045235360287471352662498L; const long double EPS = 1e-12L; int n, k, v; vector<pair<int, int>> a; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.precision(...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = raw_input() a = s.split() b = [] i = 0 while i<n: a[i] = int(a[i]) b.append(False) i += 1 tmp = sum(a)*2/n i = 0 j = 0 while i<n: if not b[i]: j = i+1 while ((a[j]+a[i]!=tmp) or b[j]): j += 1 b[j]=True b[i]=True print str(i+1)+' '+str(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...
#include <bits/stdc++.h> using namespace std; int temp; int n, m, k; int arr[101]; int res[101]; void sortV() { for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { if (arr[i] > arr[j]) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; temp = res[i]; res[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 = list(map(int, input().split())) for i in range(n): a[i] = (i + 1, a[i]) a.sort(key = lambda x: (x[1])) for i in range(n // 2): print(a[i][0], a[n - i - 1][0], sep=' ')
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { long long a[100000], n; vector<pair<int, int> > v; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) v.push_back(make_pair(a[i], i)); sort(v.begin(), v.end()); for (int i = 0; i < (v.size() / 2); i++) { cout << v[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...
/* package whatever; // don't place package name! */ import java.util.Scanner; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int [] ar = new int[n]; int sum =...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) ls = [int(i) for i in input().split()] lscopy = ls.copy() lscopy.sort() i = 0 while(i<n//2): print(ls.index(lscopy[i])+1,end=" ") ls[ls.index(lscopy[i])] = -999 print(ls.index(lscopy[n-i-1])+1) ls[ls.index(lscopy[n-i-1])] = -999 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 ln=int(sys.stdin.readline()) arr=list(map(int,sys.stdin.readline().split())) pair_sum=int(sum(arr)/(ln/2)) visited_set=set() for i in range (ln): if i in visited_set: continue visited_set.add(i) ind=arr.index(pair_sum-arr[i]) while ind in visited_set: ind=ind+1+arr[ind+1:].index(pair_sum-arr[i]) vis...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 { static Scanner sc = new Scanner(System.in); public static void main(String []args) { int a[]=new int[100]; int b[]=new int[100]; while(sc.hasNextInt()) { int n=sc.nextInt(); for(int y=0;y<100;y++) b[y]=-1; for(int i=0;i<n;i++) a[i]=sc.nextInt(); ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import sys input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) - 1])) def invr(): return(map(int,input().split())) def solve(n, a): som =...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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/python n = int(raw_input()) cards = [int(x) for x in raw_input().split(" ")] v = sum(cards)/(n/2) r = [] for i in xrange(len(cards)): for z in xrange(i,len(cards)): if cards[i] != -1 and cards[z] != -1: # print i,cards[i] # print z, cards[z] # print cards[i] + cards[z] if cards[i] + 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...
#include <bits/stdc++.h> using namespace std; long long t = 1; void solve() { long long n, s = 0, printed = 0; cin >> n; vector<long long> v(n), vv(n, 0); for (long long i = 1; i < n + 1; i += 1) { cin >> v[i - 1]; s += v[i - 1]; } s = (2 * s) / n; while (printed < n / 2) { for (long long 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()) num_list = map(int, raw_input().split()) count = 0 for num in num_list: count += num per_count = count/(n/2) for i, num in enumerate(num_list): if num == -1: continue j = i + 1 while j < len(num_list): if num + num_list[j] == per_count: print i + 1,...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) a=list(map(int,input().split())) b=sum(a)/(n/2) for i in range(n): for j in range(i+1,n): if a[i]+a[j]==b: print(i+1,j+1) a[j]=0 break
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = input() a = map(int, raw_input().split()) amt = sum(a)/(n/2) res = {} for i in range(len(a)): if a[i] not in res: res[a[i]] = [i + 1] else: res[a[i]].append(i + 1) for i in range(len(a)): diff = amt - a[i] if res[a[i]] != [] and res[diff] != []: curr_i = res[a[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...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int p[n]; for (int i = 0; i < n; i++) p[i] = i; for (int i = 0; i < n; i++) { for (int j = 0; j + 1 < n; j++) { if (a[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...
b=[] n=int(input()) a=[int(i) for i in input().split()] for i in range(n): b.append([a[i],i+1]) b=sorted(b) for i in range(int(n/2)): print(b[i][1],b[len(b)-1-i][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int,input().split())) pair = n//2 val = sum(a)//pair for i in range(n): if a[i] != 0: x = a[i] a[i] = 0 y = a.index(abs(val - x)) print(i+1,y+1) a[y] = 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()) t = list(map(int, input().split())) a = sorted([t[i], i+1] for i in range(n)) for i in range(n//2): print(a[i][1],a[-i-1][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) l=list(map(int,input().split())) a=max(l)+min(l) l1=[] for i in range(n): for j in range(i+1,n): if l[i]+l[j]==a: if i+1 not in l1 and j+1 not in l1: l1.append(i+1) l1.append(j+1) break for i in range(0,n-1,2): print(l1[i],l1[i+1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int n; struct ma { int x, vt; } a[105]; bool cmp(ma p, ma y) { return p.x < y.x; } int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].x; a[i].vt = i; } sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n / 2; i++) cout << a[i].vt << " ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) l=list(map(int,input().split())) l1=[] for i in range(n): l1.append((l[i],i)) l1.sort() for i in range(n//2): print(l1[i][1]+1,l1[-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, a = int(input()), list(map(int, input().split())) x = (2 * sum(a)) // n for i in range(n // 2): while not a[-1]: a.pop() al = a[-1] p2 = a.index(x - al) print(len(a), p2 + 1) a.pop() a[p2] = 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; inline int in() { int x; scanf("%d", &x); return x; } const int INF = 1e9 + 10; const long long LINF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100; const int MN = 1e2 + 10; bool mk[MN]; vector<pair<int, int> > ans; int arr[MN]; int n; int main() { ios_base ::syn...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 number; cin >> number; int arr[number][2]; for (int i = 0; i < number; i++) { cin >> arr[i][0]; arr[i][1] = i + 1; } for (int i = 0; i < number; i++) { for (int j = i; j < number; j++) { if (arr[i][0] > arr[j][0]) { swa...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int A[n]; int sum = 0; for (int i = 0; i < n; i++) { cin >> A[i]; sum += A[i]; } int ans = sum * 2 / n; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if ((A[i] + A[j]) == ans) { co...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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(k) for k in input().split(" ")] a=sum(L)//(n//2) for k in range(n-1): for j in range(k+1,n): if(L[k]+L[j]==a): print(k+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...
n = int(input()) text = input() x = [] c = 0 for i in range(0, n): x.append(int(text.split(" ")[i])) c += int(text.split(" ")[i]) c = c / (n / 2) history = [] sch = 0 for i in range(0,len(x)): for b in range(0, len(x)): if i != b: if history.count(str(b)) == 0 and history.count(str(i)) ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int> > nums; int temp; for (int i = 0; i < n; ++i) { cin >> temp; nums.push_back(make_pair(temp, i)); } sort(nums.begin(), nums.end()); for (int i = 0; i < n / 2; ++i) { cout << nums[i].second + 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())) spis=[False]*n b=sum(a)/(n/2) i=0 k=1 while i<n: while k<n: if a[i]+a[k] == b and spis[i] == False and spis[k] == False: spis[i] = True spis[k] = True print(i+1,k+1) k=k+1 i=i+1 k=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; const double eps = 1e-8; const int mod = 1000000007; const double PI = acos(-1.0); struct node { int x, y; }; int a[1005]; int b[1005]; int c[1005]; char s[1005]; bool vis[1005]; int n, m; int ans; int main() { int tt, ca = 1; int p, q; scanf("%d", &n); int sum = ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int l1; cin >> l1; int r1[l1 + 5]; vector<pair<int, int> > v; for (int i = 1; i <= l1; i++) { cin >> r1[i]; v.push_back(make_pair(r1[i], i)); } sort(v.begin(), v.end()); for (int i = 0; i < l1 / 2; i++) { cout << v[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.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.Arrays; public class Cards { public static void main(String[]args)throws IOException,NumberFormatException{ BufferedReader bf =new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Round364D { public static void main(String[] args) throws NumberFormatException, IOException { ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 MAX = 1e2 + 1; pair<int, int> t[MAX]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> t[i].first; t[i].second = i + 1; } sort(t, t + n); for (int i = 0; i < n / 2; i++) { cout...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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<int> v; vector<int> c; for (int i = 0; i < n; ++i) { int a; cin >> a; v.push_back(a); c.push_back(a); } sort(v.begin(), v.end()); for (int i = 0; i < n / 2; ++i) { int pos = find(c.begin(), c.end(), 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...
import java.awt.Point; import java.io.*; import java.math.*; import java.util.*; public class Main implements Runnable { int maxn = (int)2e2+200; int mod = (int)1e9+7; int inf = (int)1e9; int n,m,k; int a[] = new int[maxn]; void solve() throws Exception { 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...
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, -1, 1}; int dy[] = {1, 1, 0, 0}; int a[50000]; bool taken[1000]; int main() { int n, s = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; s += a[i]; } s = s / (n / 2); for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = [int(i) for i in input().split()] sum = 0 for item in a: sum += item i = 0 j = 0 while a != [0] * n: if a[i] == 0: i += 1 if a[j + 1] == 0: j += 1 if j + 1 == n: j = -1 if i != j + 1 and a[i] + a[j + 1] == sum / (n / 2): print(i + 1, j + 2) ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> const long long MaxN = 1e5 + 50; using namespace std; pair<int, int> a[111]; int main() { int n; cin >> n; 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;...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())) m=max(l)+min(l) a=[] for i in range(n): if l[i]!=0: for j in range(i+1,n): if l[i]+l[j]==m: a.append(i+1) a.append(j+1) l[i]=0 l[j]=0 for i in range(0,n,2): print(a[i],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())) sum=0 flag=[] for i in range(0,n+1): flag.append(0) lag=flag for i in a: sum=sum+ i sum=sum//(n/2) for i in range(n+1): for j in range (i,n): if a[i]+a[j]==sum and i!=j and flag[i]==0 and lag[j]==0: flag[i]=1 lag[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...
a=int(input()) b=list(map(int, input().split())) c=[] for i in range(a): c.append([b[i],i]) c. sort() for i in range(a//2): print(str(c[i][1]+1)+" "+str(c[a-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 = int(raw_input()) cards = map(int, raw_input().split()) cards_pos = {} for i in xrange(0, n): if cards[i] in cards_pos: cards_pos[cards[i]].add(i) else: cards_pos[cards[i]] = set([i]) cards = sorted(cards) for i in xrange(0, n/2): x = cards_pos[cards[i]].pop() + 1 y = cards_pos[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...
#include <bits/stdc++.h> int main() { int n, N[100], S = 0, i, j; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &N[i]); S = S + N[i]; } int A = S / (n / 2); for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (A - N[i] == N[j]) { printf("%d %d\n", 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; const int maxn = 1e3 + 10; pair<int, int> a[maxn]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; a[i].first = x, a[i].second = i; } sort(a + 1, a + n + 1); for (int i = 1; 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...
n=int(input()) L = [int(x) for x in input().split()] A = [0]*101 d = {} for j in range(n): i = L[j] A[i] +=1 if i not in d: d[i] = [] d[i].append(j) req = (2*sum(L))//n for i in range(101): while A[i]: print(d[i].pop()+1, d[req-i].pop()+1) A[i] -= 1 A[req-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())) sum = sum(a) sumOne = sum // (n // 2) used = [] for i in range(n): for k in range(i + 1, n): if i not in used and k not in used and a[i] + a[k] == sumOne: used.append(i) used.append(k) print(i + 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...
input() a = list(map(int , input().split())) num = sum(a)//(len(a)//2) i=0 x=1 arr = [] for g in range(0,len(a)): arr.append(1) for i in range(0,len(a)): if arr[i]==1: while x<len(a): if a[i]+a[x]==num and arr[x]==1 and i!=x: print(i+1,x+1) arr[i]=0 ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int,input().split())) for i in range(n): a[i] = (a[i], i + 1) a.sort() for i in range(n//2): print(a[i][1], a[n-i-1][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
def main(): n = int(input()) a = list(map(int, input().split())) s = sum(a) // (n // 2) for i in range(n): if a[i] != -1: c, d = a[i], s - a[i] c = a.index(c) a[c] = -1 d = a.index(d) a[d] = -1 print(c + 1, d + 1) if __na...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()] z=sum(a) z=z/len(a)*2 s=len(a)*[0] for i in range(len(a)): for j in range(len(a)): if i!=j: if a[i]+a[j]==z and s[i]!=1 and s[j]!=1: print(i+1,j+1,end=' ') print() s[i]=1 s[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...
def pro(): n = int(input()) h = list(map(int, input().split())) q = h.copy() q.sort() for i in range(n // 2): print(h.index(q[i]) + 1, end = ' ') h[h.index(q[i])] = -1 print(h.index(q[-1 - i]) + 1) h[h.index(q[-1 - i])] = -1 pro()
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 static java.lang.Math.abs; public class main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int a = in.nextInt(); int[] arr = new int[a]; int[] index = new int[a]; int ind = 1; for(int i=0;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...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 100500; const int maxn = 100500; int main() { int n; cin >> n; vector<pair<int, int> > arr; for (int i = 0; i < n; i++) { int temp; cin >> temp; arr.push_back(pair<int, int>(temp, i + 1)); } sort(arr.begin(), arr.end()); 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...
#include <bits/stdc++.h> using namespace std; int n; int a[100 + 2]; int d[100 + 2]; bool cmp(int x, int y) { return a[x] < a[y]; } int main() { scanf("%d", &n); for (register int i = 1; i <= n; ++i) { scanf("%d", &a[i]); d[i] = i; } sort(d + 1, d + n + 1, cmp); for (register int i = 1; i <= n / 2; ++...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(raw_input()) cards = map(int, raw_input().split()) sum = 0 for i in range(0,len(cards)): sum+=cards[i] sum/=(n/2) count = 0 for j in range(0, n): for k in range(1,n): if cards[j]+cards[k]==sum and k!=j: print j+1, k+1 cards[k] = 0 cards[j] = 0
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i].first; arr[i].second = i + 1; } sort(arr, arr + n); for (int i = 0; i < n / 2; i++) { cout << arr[i].second << ' ' << arr[n - 1 - i].second << '\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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.TreeSet; public class A364 { public static void main(String[] args)throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextIn...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) a=[int(x) for x in input().split()] b=sum(a)*2//n for i in range(n): if b-a[i] in a: c=a.index(b-a[i],i+1) print(i+1,c+1) a[i]=-100 a[c]=-100
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
def index(L,n): for i in range(len(L)): if L[i]==n: return i+1 a=input() L=[int(x) for x in raw_input().split()] M=[] for i in range(1,a+1): M.append(i) X=zip(L,M) X.sort() #print X for i in range(a/2): print X[i][1],X[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()) li=list(map(int,input().split())) valu=sum(li)//(n//2) for i in range(n): for j in range(n): if li[i]+li[j]==valu: if i==j: break print(i+1,j+1) li[i]=0 li[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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.StringTokenizer; public class codeforces { static int oo = 987654321; public static void main(String[] args) throws IOExcepti...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) a=list(map(int, input().split())) p=[] for i,j in enumerate(a): p.append([i+1,j]) p.sort(key=lambda x: x[1]) for j in range(n//2): print(p[j][0], p[(n-1)-j][0])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
def main(): n = int(input()) // 2 a = [int(i) for i in input().split()] import copy cp = copy.copy(a) cp.sort() i, j = 0, len(cp) - 1 while n != 0: im = a.index(cp[i]) a[im] = None jm = a.index(cp[j]) a[jm] = None print('{} {}'.format(im+1,jm+1)) i += 1 j -= 1 n -= 1 if __name__ == '__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...
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub String S[] =r(); int n = Int(S[0]); S = r(); int arr[] = new int [ n]; int peoples = n/2; long sum=0; for (int i=0;i<n;i++) { arr[i]=Int(S[i]); ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n, avg, sum = 0; cin >> n; int A[n]; for (int i = 0; i < n; i++) { cin >> A[i]; sum = sum + A[i]; } avg = (sum * 2) / n; for (int i = 0; i < n - 1; i++) for (int j = i + 1; j < n; j++) { if ((A[i] + A[j]) == avg) { co...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = [{ "index": 0, "value": 0}]*n for i in range(n): b[i] = { "index": i+1, "value": a[i]} b.sort(key=lambda k: k['value']) for i in range(n//2): print(b[i]['index'], b[n-i-1]['index'])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int,input().split())) b = a.copy() a.sort() k = sum(a) * 2 // n for i in range(n // 2): m = b.index(a[i]) b[m] = 0 n = b.index(a[- i - 1]) b[n] = 0 print(m + 1,n + 1)
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int, input().split())) for i, j in enumerate(a): a[i] = (i, j) a = sorted(a, 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...
n = int(input()) a = input() A = [] B = [] C = [] for i in a.split(): A.append(int(i)) x = sum(A)/n*2 z = 0 for i in range(0,n): if (i in C) == False: for j in range(i+1,n): if A[i] + A[j] == x and ((j in C) == False): B.append([i+1,j+1]) C.append(j) ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) a=list(map(int,input().split())) pii=[[None,None]]*n for i in range(0,n): pii[i]=[a[i],i+1] pii.sort() for i in range(0,n//2): print(pii[i][1],pii[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...
bla=int(raw_input()) ba=raw_input().split() c=[] for t in ba: c.append(int(t)) s=sum(c)*2/bla paired=[] for i in range(bla): paired.append(False) def firstunpaired(): for i in range(len(c)): if paired[i]==False: return i return -1 def findunpaired(num): for i in range(le...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) b=range(1,n+1) b.sort(key=lambda x : a[x-1]) for i in range(n/2): print b[i],b[-i-1]
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(int(input())/2) a = list(map(int, input().split())) x = int(sum(a)/n) b = [] for i in range(len(a)): if i in b: continue else: for j in range(i+1,len(a)): if j in b: continue if a[i] + a[j] == x: print(i+1, j+1, ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.Scanner; public class ChoosingTeams { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] array = new int[n]; int sum = 0; boolean[] got = new boolean[n]; for (int i = 0; i < n; i++) { array[i] = scan.nextInt(); sum += 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.IOException; import java.util.LinkedList; import java.util.Scanner; public class Solutions { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); LinkedList<Integer> list = new LinkedList<Integer>(); int s = 0; for(in...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.*; import java.util.*; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author root */ public class AX { static class Pair implements Comparable { ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j, sum = 0; cin >> n; long long a[n], v[n]; for (i = 0; i < n; i++) { v[i] = 0; cin >> a[i]; sum += a[i]; } long long x = n / 2; sum = sum / x; for (i = 0; i < n; i++) { if (v[i] == 0) { v[i] = 1; 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...
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Collections.*; import static java.util.Arrays.*; public class CodeforcesRound364Div2ProblemA { static class Problem { Scanner reader; PrintWriter writer; Problem() { reader = new Scanner(Sy...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int sum, jam; int main() { int n, a[100]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } jam = sum / (n / 2); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] + a[j] == jam) { cout << 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 = input() a = map(int,raw_input().split()) aux = [ (a[0],1) ] for i in range(1,n): aux.append((a[i],i+1)) aux = sorted(aux) i = 0 j = n-1 while i<j: print aux[i][1], ' ', aux[j][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(input()) ma=0 mi=101 s=list(map(int,input().split())) for i in range(n): if s[i]<mi: mi=s[i] if s[i]>ma: ma=s[i] s[i]=(s[i],i+1) su=mi+ma s=sorted(s) for i in range(len(s)//2): print(s[i][1],s[len(s)-i-1][1])