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...
z=int(input()) x=list(map(int,input().split())) f=sorted(x) a=-1 for c in range(z//2): q=x.index(f[c])+1 x[x.index(f[c])]=0 w=x.index(f[a])+1 x[x.index(f[a])]=0 print(q,w) a-=1
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; float av, sum; for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; } av = (sum / n) * 2; for (int i = 1; i <= n; i++) { if (a[i] != 0) { for (int j = 1; j <= n; j++) { if (a[i] + a[j] == ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) l=list(map(int,input().split())) m=max(l)+min(l) for i in range(n): for j in range(n): if(l[i]+l[j]==m and i!=j): print(i+1,j+1) l[i]=369 l[j]=369
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()); line = input() s = line.split() sum = 0 for i in range(0,n): sum += int(s[i]) sum /=(n/2) for i in range(0,n): if s[i] != -1: for j in range(0,n) : if int(s[i])+int(s[j]) == sum and int(s[j]) != -1 and i != j : ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.ArrayList; import java.util.Scanner; public class Main { static ArrayList<Integer> a = new ArrayList<>(); static String shift(String s) { s = s.charAt(s.length() - 1) + s; s = s.substring(0, s.length() - 1); return s; } public static void main(String[] strin...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 cards { public static void main(String args[]) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int a[]=new int[n]; int b[]=new int[n]; int i,j,key,key1; for(i=0;i<n;i++) { a[i]=in.nextInt(); ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) l=sorted(zip(map(int,input().split()),range(1,1+n))) for i in range(n>>1): print(l[i][1],l[-1-i][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Cards { public static BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); public static StringTokenizer st; public static void m...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) m = list(map(int,input().split())) g = n//2 s = sum(m)//g used = [] t = [] for i in range(n): for j in range(i+1,n): if (i not in used and j not in used) and m[i]+m[j]==s: print(i+1,j+1) used.append(i) used.append(j) break
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tam = sc.nextInt(); int sum = 0; int[] arr = new int[tam]; int[] arr2 = new int[tam]; for (int i = 0; i < tam; i++) { 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 = input() a = map(int, raw_input().split()) s = sum(a) t = s / (n/2) for i in range(n): if a[i] != -1: p = a[i] a[i] = -1 m = a.index(t-p) a[m] = -1 q = t-p if p < q: print i+1, m+1 else: print m+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; void pairsort(long long int arr[], long long int index[], long long int n) { pair<int, int> p[n]; for (long long int i = 0; i < n; i++) { p[i].first = arr[i]; p[i].second = index[i]; } sort(p, p + n); for (long long int i = 0; i < n; i++) { arr[i] = p[...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, forEach; cin >> n; pair<int, bool> card[n]; for (int i = 0; i < n; i++) { cin >> card[i].first; sum += card[i].first; card[i].second = true; } forEach = sum / (n / 2); for (int i = 0; i < n; i++) { if (card[i].secon...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())) x=int((sum(l)/n)*2) y=[] for i in range(n): for j in range(i+1,n): if(i+1 not in y and j+1 not in y): if(l[i]+l[j]==x): print(i+1,j+1) y.append(i+1) y.append(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 CR364A { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = s.nextInt(); } int min = a[0]; int max = 0; for (int i = 0; i < n; i++) { min = Math.m...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.Scanner; public class x1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int c = sc.nextInt(); int[][] a = new int[2][c]; int sum = 0; for( int i = 0 ; i < c ; i++) { a[0][i] = sc.nextInt(); sum = sum + a[0][i]; } int avg = sum/(c/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> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long n, a; cin >> n; vector<pair<long long, long long>> v; for (long long i = 0; i < n; i++) { cin >> a; v.push_back({a, i + 1}); } sort((v).begin(), (v).end()); ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, d, m; cin >> n; int a[105]; for (int i = 0; i < n; ++i) { cin >> d; sum += d; a[i] = d; } m = sum / (n / 2); for (int i = 0; i < n; ++i) { for (int j = i + 1; j <= n; ++j) { if (a[i] + a[j] == m) { cou...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 sort(int A[], int l, int r) { if (r - l < 2) { return; } int mid = (r + l) / 2; sort(A, l, mid); sort(A, mid, r); int B[r - l]; int x = l; int y = mid; for (int i = 0; i < r - l; i++) { if (A[x] <= A[y] && x < mid && y < r) { B[i] = A[x]...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import sys import math #to read string get_string = lambda: sys.stdin.readline().strip() #to read list of integers get_list = lambda: list( map(int,sys.stdin.readline().strip().split()) ) #to read non spaced string and elements are integers to list of int get_intList_from_str = lambda: list(map(int,list(sys.stdin.read...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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; map<string, long long int> month; void Month() { month["January"] = 1, month["February"] = 2, month["March"] = 3, month["April"] = 4, month["May"] = 5, month["June"] = 6; month["July"] = 7, month["August"] = 8, month["September"] = 9, month["October"] = 10, month["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...
k=int(input()) a=list(map(int,input().split())) d=(sum(a)*2)//k for i in range(len(a)-1): for j in range(i+1,len(a)): if(a[i]+a[j]==d): print(i+1,j+1) a[i]=0 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=int(input()) n2=n//2 x=list(map(int,input().split())) xs=sum(x) xs=xs//n2 count=0 for i in range(len(x)-1): for j in range(i+1,len(x)): if x[i]+x[j]==xs: print(str(i+1)+" "+str(j+1)) x[i]=0 x[j]=0 count+=1 if count==n2: exit()
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())) min1 = min(l)+max(l) for i in range(n): for j in range(n): if l[i]+l[j]==min1 and i!=j: print(i+1,j+1) l[i] = 0 l[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...
n=int(input()) l=list(map(int,input().split())) d=dict() for i in range(1,n+1): d[i]=l[i-1] d=dict(sorted(d.items(),key=lambda x:(x[1],x[0]))) a,b=1,n g=[] g.append(0) for x in d.keys(): g.append(x) for i in range(n//2): print(g[a],g[b]) 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...
cards = int(input()) string = input() values = string.split(" ") for x in range(cards): values[x] = int(values[x]) sums = int(sum(values) / (cards / 2)) chosen = [] card = 0 while len(chosen) != cards: if not card + 1 in chosen: chosen.append(card + 1) for x in range(cards): if value...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import sys data = sys.stdin.readlines() n = int(data[0]) numb = [int(i) for i in data[1].split()] s = sorted(numb) summ = s[0] + s[-1] for i,v in enumerate(s): a1 = numb.index(v) numb[a1] = 0 a2 = numb.index(summ - v) numb[a2] = 0 print(a1 + 1,a2 + 1) if i == n/2 - 1: break ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; struct Card { int num, pos; } cards[105]; bool cmp(Card c1, Card c2) { return c1.num < c2.num; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &cards[i].num); cards[i].pos = i; } sort(cards + 1, cards + 1 + n, cmp); 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...
n = int(raw_input()) arr = raw_input().split() total = 0 for i in range(0,len(arr)): arr[i] = int(arr[i]) total += arr[i] sum = (2*total)/n first_value =0 second_value =0 first_card =0 second_card =0 for m in range(0,n/2): start_ind = 0 for i in range(start_ind,len(arr)): if(arr[i] > 0): start_ind = i first...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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());b=list(map(int,input().split()));d=sorted([[b[i],str(i+1)] for i in range(n)]) for i in range(n//2):print(d[i][1],d[-i-1][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class A { static class Card implements Comparable<Card> { int ind; int number; public Card(int ind, int number) { this.ind = ind; this.number ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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=sorted(l) s=m[0]+m[n-1] c=0 for i in range(n): for j in range(i+1,n): if(l[i]+l[j]==s): print(i+1,j+1) l[i]=0 l[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() { long long int n; cin >> n; pair<long long int, long long int> a[n]; for (long long int i = 0; i < n; i++) { cin >> a[i].first, a[i].second = i + 1; } sort(a, a + n); for (long long int i = 0; i < n / 2; i++) { cout << a[i].second << " " <<...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.Scanner; public class Cards { public static void main(String[] args) { Scanner s = new Scanner (System.in ); int n =s.nextInt(), a[]=new int [n],sum=0; for (int i = 0; i < n; i++) { a[i]=s.nextInt();sum+=a[i];} sum=sum/(n/2); for (int i = 0; i < ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) arr = list(map(int, input().split(' '))) l = [] for i in range(n): l.append([i+1, arr[i]]) l = sorted(l, key=lambda x:x[1]) for i in range(n//2): print(str(l[i][0]) + ' ' + str(l[n-i-1][0]))
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
def sort_key(a): return a[0] n = int(input()) data = [int(i) for i in input().split()] for i in range(n): data[i] = [data[i], i + 1] data.sort(key = sort_key) for i in range(n // 2): print(data[i][1], data[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...
def ind(N, el, B, A): for i in range(N): if B[i]: if A[i] == el: return i return 0 N = int(input()) A = list(map(int, input().split())) B = [True for i in range(N)] summ = (sum(A) * 2) // N for i in range(N): if B[i]: B[i] = False x = ind(N, summ - A[i], B, A) B[x] = False print(i + 1, x + 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...
num = int(input()) list = [int(x) for x in input().split(" ")] list_1 = list.copy() list_1.sort() sum = list_1[-1]+list_1[-2] while sum>0: dic = {} count = 0 for i in range(num): test = sum-list[i] if test not in list: break else: for m in range(num): ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; long long n; struct arr { int val, pos; }; arr v[102]; bool cmp(arr a, arr b) { return a.val < b.val; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; ++i) cin >> v[i].va...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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...
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class A { private static ArrayList<Map.Entry<Integer, Integer>> arr = new ArrayList<>(); public static void main(String[] args) throws Exception { FastScanner in = new FastScanner(); int n = in.nextI...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
# Description of the problem can be found at http://codeforces.com/problemset/problem/701/A n = int(input()) l_c = list(map(int, input().split())) l_i = list() for i in range(n): l_i.append(i + 1) l_ci = sorted(zip(l_c, l_i)) for i in range(n // 2): print("%d %d" % (l_ci[i][1], l_ci[len(l_ci) - 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 sol(A): n=len(A) V=[0]*n summ=min(A)+max(A) pairs=[] for i in range(n): for j in range(i,n): if(A[i]+A[j]==summ and V[i]==0 and V[j]==0 and i!=j): V[i],V[j]=1,1 pairs.append([i,j]) return pairs if(__name__=='__main__'): n=int(input()) ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; public class Cards impleme...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.BufferedReader; /* Codeforces Round #364 (Div. 2) * Cards * @author : raghumdani */ public...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())) val=2*sum(arr)//n arr1=[0]*n i=0 ansarr=[] while(i<n): if(arr1[i]==0): for j in range(i+1,n): if(arr1[j]==0): if(arr[i]+arr[j]==val): print(i+1,j+1) arr1[i]=1 arr1[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()) cards = list(map(int, input().split())) a = [] for i in range(n): a.append([cards[i], i]) a.sort(key=lambda x: x[0]) for i in range(n // 2): x, y = a[i][1], a[n - i - 1][1] print(str(x + 1) + ' ' + str(y + 1))
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) l=list(map(int,input().split())) l1=[] for i in range(1,n+1): l1.append((i,l[i-1])) l1.sort(key=lambda l1:l1[1]) # print(l1) for i in range((n//2)): print(l1[i][0],l1[n-1-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()) arr = list(map(int, input().split())) c = [] for i in range(n): c.append(arr[i]) c.sort() for i in range(n // 2): a = arr.index(c[i]) arr[a] = -1 b = arr.index(c[n - i - 1]) #print(a, b) print(a + 1, b + 1) arr[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...
I = lambda:list(map(int,raw_input().split())) n = int(input()) ls = I() min_l = min(ls) max_l = max(ls) sum_l = min_l+max_l for i in range(n-1): if ls[i] != 0: for j in range(i+1,n): if ls[i]+ls[j]==sum_l and ls[i]!=0 and ls[j]!=0: print i+1,j+1 ls[i] = -10 ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.math.BigInteger; import java.util.*; import java.util.stream.IntStream; public class random_num { public static long ma=(lon...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 def cards(arr): ans = [] di = {} for i, j in enumerate(arr): if j in di: di[j].append(i+1) else: di[j] = [i+1] while arr: smol = min(arr) big = max(arr) val = [di[smol].pop(), di[big].pop()] arr.remove(smol) arr.remo...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 701 - div 2 a n = int(raw_input()) num_cards = map(int, raw_input().split()) qtd = sum(num_cards) / (n/2) used_cards = [] for i in range(len(num_cards)): for j in range(i+1, len(num_cards)): if not (i in used_cards or j in used_cards): if num_cards[i] + num_cards[j] == qtd: 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...
def main(): n = int(input()) nums = list(map(int,input().split())) cards = [] for i in range(n): cards.append((nums[i],i+1)) cards = sorted(cards,key = lambda x: x[0]) ans = [] #print (cards) for i in range(int(n/2)): ans.append((cards[i][1],cards[n-i-1][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...
n = int(input()) arr = [int(i) for i in input().split(' ')] sum = sum(arr)//(n//2) vis = [int(0) for i in range(int(1e2+5))] for i in range(n): for j in range(n): if(arr[i]+arr[j] == sum and i!=j and vis[i]|vis[j] == False): print(i+1,j+1) vis[i] = vis[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=[int(i) for i in input().split()] d=sum(a) e=d//(len(a)//2) m=[] c=0 for i in range(0,len(a)): for j in range(0,len(a)): if(a[i]+a[j]==e and j!=i and (i+1 not in m) and (j+1 not in m)): print(i+1,j+1) m.append(i+1) m.append(j+1) c=c+2 # ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.util.*; public class RHO { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; int b[]=new int[n]; for(int i=0;i<n;i++) {a[i]=sc.nextInt();b[i]=a[i];} Arrays.sort(b); int k=b[0]+b[n-1]; boolean v[]=new boolean[n]; for(int i=0;i<n;i++) { for(int...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 s[105]; bool chk[105]; int main() { int n, i, j, sum = 0, pv; cin >> n; for (i = 1; i <= n; i++) { cin >> s[i]; sum += s[i]; } pv = sum / (n / 2); for (i = 1; i <= n; i++) { if (chk[i]) continue; for (j = i + 1; j <= n; j++) { if (chk[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 Solution701A { private static PrintWriter out; public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer = new StringTokenizer(br.readLine...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double EPS = 1e-7; const int inf = 1e8; int main() { int n, sum = 0; cin >> n; vector<int> in(n); for (int i = 0; i < n; i++) cin >> in[i]; for (int i = 0; i < n; i++) sum += in[i]; vector<int> used(n); for (int i = 0; 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()) a = list(map(int, input().split())) s = sum(a) deck = {} for i, card in enumerate(a): if card not in deck: deck[card] = {i} else: deck[card].add(i) all_card_numbers = set(range(n)) target = s // (n // 2) for i, card in enumerate(a): if i not in all_card_numbers: ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
from collections import defaultdict n = int(input()) cards = [int(c) for c in input().split()] _sum = sum(cards) // (len(cards) // 2) pos = defaultdict(list) for i, e in enumerate(cards, 1): pos[e].append(i) for k, v in pos.items(): while pos[k]: print(pos[k].pop(), pos[_sum - k].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() { int n; cin >> n; vector<int> a; vector<int> arr[101]; for (int i = 0; i < n; i++) { int p; scanf("%d", &p); a.push_back(p); arr[p].push_back(i + 1); } int cnt[101]; for (int i = 0; i < 101; i++) { cnt[i] = -1; } sort(a.be...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()) l = list(map(int, input().split())) idx = sorted(range(n), key=l.__getitem__) for a, b in zip(idx[:n // 2], idx[::-1]): print(a + 1, b + 1) if __name__ == "__main__": main()
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
cards = int(input()); b = [int(x) for x in input().split()]; c=[]; for i in range(0,len(b)): lowIndex = b.index(min(b)); b[lowIndex]=9999; c.append(lowIndex); for i in range(0,int(len(b)/2)): print(c[i]+1, " ", c[len(c)-(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; struct node { int id, date, flag; } s[110]; int cmp(node a, node b) { return a.date < b.date; } int main() { int n; while (scanf("%d", &n) != EOF) { int sum = 0; for (int i = 0; i < n; i++) { scanf("%d", &s[i].date); s[i].id = i + 1; s[i].fla...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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=[] idx=[] data=input() data=data.split(' ') for i in range(n): arr.append(int(data[i])) idx.append(int(i+1)) for i in range(n): for j in range(n): if(arr[i]>arr[j]): arr[i],arr[j]=arr[j],arr[i] idx[i],idx[j]=idx[j],idx[i] for i in range(n//2): print(str(idx[i])+" "+str(idx[n-i-1]))
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int, input().split())) tmp = (sum(a) // (n // 2)) m = [] if n == 2: print(1, 2) exit() for i in range(0, n): if i in m: continue else: for j in range(i + 1, n): if j in m: continue if a[i] + a[j] == tmp: ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = raw_input() n = int(n) a = map(int,raw_input().split()) c = n/2 b = sum(a)/c for i in range(0,n): for j in range(0,n): if i!=j: if a[i]+a[j]==b: print i+1,j+1 a[i]=0 a[j]=0
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.HashMap; import java.util.Stack; public class main { static class FastReader { Buffe...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 mod(n): if n>0: return n return (-n) n = int(raw_input()) a = [] #for i in range(n): # temp=int(raw_input().split()) # a.append(temp) nums=raw_input().split(" ") for i in range(n): a.append(int(nums[i])) avg = 2*sum(a)/len(a) np = n/2 for i in range(n): if a...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; int n, sum = 0, c = 0, x; cin >> n; int d = n / 2; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); sum += x; } int a = sum / d; for (int i = 0; i < v.size(); i++) { for (int j = i + 1; j < v.size(); j++) { ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) l = list(map(int, input().split())) s = int(sum(l) / (n/2)) d=[] for i in range(n): if l[i]<0: continue for j in range(n): if l[j]<0: continue if l[i]+l[j]==s and i!=j: d.append((i+1, j+1)) l.pop(i) l.insert(i,-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...
n = int(input()) arr = sorted([(int(elem), i+1) for i, elem in enumerate(input().split())]) l = len(arr) for i in range(0, int(l/2)): print(arr[i][1], arr[l-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> const int M = 300000; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, x; cin >> n; vector<pair<int, int> > v; for (int i = 1; i <= n; i++) { cin >> x; v.push_back(make_pair(x, i)); } sort(v.begin(), v.end()); for (int i = 0, j = 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...
/* *In the name of Allah the Most Merciful. * Author * Md. Toufiqul Islam * Dept. Of CSE * Ahsanullah University Of Science And Technology * * Codeforces,Round 364,Problem A */ import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class R364A { public static void main(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...
#include <bits/stdc++.h> using namespace std; int main() { int p, sum = 0; cin >> p; int a[p]; for (int i = 1; i <= p; i++) { cin >> a[i]; sum += a[i]; } sum = sum / (p / 2); for (int i = 1; i <= p; i++) { for (int j = 1; j <= p; j++) { if (i != j) { if (a[i] + a[j] == 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()) a = list(map(int, input().split())) used = [False] * len(a) s = sum(a) // (n // 2) for i in range(n // 2): for t in range(len(a)): if not used[t]: pos = t break for t in range(len(a)): if not used[t] and t != pos and a[t] + a[pos] == s: 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...
a = int(input()) s = [int(x) for x in input().split()] s1 = sorted(s) for i in range(a // 2): print(s.index(s1[i]) + 1, end=" ") s[s.index(s1[i])] = 0 print(s.index(s1[a - i - 1]) + 1) s[s.index(s1[a - i - 1])] = 0
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input()) l=list(map(int,input().split())) nx=n/2 sm=int(sum(l)/nx) nl=[] for i in range(n): if i not in nl: nl.append(i) for j in range(i+1,n): if l[i]+l[j]==sm and j not in nl: print(i+1,j+1) nl.append(j) break
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class ProblemA { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamRe...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()] ans=[] for i in range(0,n): ans.append((l[i],i+1)) ans.sort() l=0 #print(ans) r=n-1 while l<r: print(ans[l][1],ans[r][1]) l+=1 r-=1
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=input() a=map(int,raw_input().split()) s=sum(a) x=2*s/n f=[0]*n for i in range(n): if f[i]==0: for j in range(i+1,n): if a[j]+a[i]==x and f[j]==0: print i+1,j+1 f[i]=1 f[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()) line = list(map(int, input().split())) Sum = int(sum(line)/(n/2)) matrix = [] Count = a = 0 check = [] check2 = [] for i in range(n): for j in range(n): if i not in check and j not in check2 and j not in check and i not in check2: if i != j: if line[i] + line[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(a), i+1) for i, a in enumerate(input().split())] 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...
n = input() n = int(n) s = input() L1 = s.split() L2 = [i for i in range(1,n+1)] L3 = list(zip(L1,L2)) L4 = sorted(L3,key=lambda x:int(x[0])) for i in range(n//2): print(L4[i][1],L4[-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; struct P { int val, index; P(int _val, int _index) : val(_val), index(_index) {} }; int main() { int n; cin >> n; vector<P> a; for (int i = 0; i < n; i++) { int val; cin >> val; a.emplace_back(val, i + 1); } sort(begin(a), end(a), [](const...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = [] S = sum(a)/(n/2) for i in range(n): for j in range(i+1,n): if (a[i]+a[j])==S and i not in b and j not in b: print(i+1,j+1) b.extend((i,j))
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import java.io.*; import java.util.*; public class template { public static void main(String[] args) throws IOException { FastReader scan = new FastReader(); //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("teamwork.out"))); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputSt...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int, input().split())) b = sum(a) // (n // 2) d = [] for i in range(n): for j in range(n): if (a[i] + a[j] == b) and j>i: if i+1 not in d and j+1 not in d: d.append(i+1) d.append(j+1) for i in range(n//2): print(d[0],d[1]) d....
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n=int(input());inp=sorted([(j,i) for (i,j) in enumerate(map(int,input().split()),1)]) i=0; while(i<int(n/2)): print(inp[i][1],inp[n-i-1][1]) i+=1
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import sys n = int(input()) arr = list(map(int,input().split())) arr2 = sorted(arr) arr3=[] for i in range(n): j = i + 1 a = arr2[i] b = arr2[n-j] for k in range(n): if(arr[k] == a and k+1 not in arr3 ): arr3.append(k+1) break for l in range(n): if (arr[l] =...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
# -*- coding: utf-8 -*- """ Created on Sun Jun 2 15:21:54 2019 @author: avina """ n = int(input()) l = input().split() l = [(int(l[i]), i+1) for i in range(n)] l.sort(key=lambda x:x[0]) for i in range(n//2): print(l[i][1],l[n-i-1][1])
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) m = list(map(int, input().split())) a = list(m) a.sort(reverse = True) for i in range(n // 2): b = m.index(a[0]) m[b] = None c = m.index(a[-1]) m[c] = None print(b + 1, c + 1) a = a[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()) #n, m = map(int, input().split()) #s = input() c = list(map(int, input().split())) k = min(c) + max(c) for i in range(n): if c[i] != 0: for j in range(i + 1, n): if c[i] + c[j] == k: c[i] = 0 c[j] = 0 print(i + 1, j + 1) ...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { long long a[500]; long long i, n, k, t, j; cin >> n; long long sum = 0; for (i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } t = sum / (n / 2); for (i = 0; i < n; i++) { if (a[i]) for (j = i + 1; j < n; j++) { if (a[j]...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; struct Matrix { long long mat[2][2]; }; Matrix MatMul(Matrix a, Matrix b) { Matrix ans; int k; for (int i = (0); i < (2); i++) for (int j = (0); j < (2); j++) for (ans.mat[i][j] = k = 0; k < 2; k++) ans.mat[i][j] = (ans.mat[i][j] + (a.m...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; struct NODE { int x; int y; }; bool cmp(NODE a, NODE b) { return a.x < b.x; } NODE ans[105]; int main() { int n; cin >> n; if (n % 2 == 0) { for (int i = 1; i <= n; i++) { cin >> ans[i].x; ans[i].y = i; } sort(ans + 1, ans + n + 1, 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...
n = int(input()) a = list(map(int, input().split())) x = [] for i in range(n): x.append([a[i],i]) x = sorted(x, key = lambda x: x[0]) for i in range(n//2): print(x[i][1]+1,x[n-i-1][1]+1, sep = " ")
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
# Author: S Mahesh Raju # Username: maheshraju2020 # Date: 30/04/2020 from sys import stdin,stdout from math import gcd, ceil, sqrt ii1 = lambda: int(stdin.readline().strip()) is1 = lambda: stdin.readline().strip() iia = lambda: list(map(int, stdin.readline().strip().split())) isa = lambda: stdin.readline().strip().sp...