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... | n = int(input().strip())
ins = input().strip().split(' ')
a = []
for i in range(n):
a.append((int(ins[i]),i+1))
a.sort(key=lambda tup: tup[0])
for i in range(int(n/2)):
print(a[i][1], a[n-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
struct node {
int num, pos;
} a[105];
bool cmp(node x, node y) { return x.num < y.num; }
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i].num);
a[i].pos = i;
}
sort(a + 1, a + 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()))
for i in range(n):
A[i] = (A[i],i+1)
A.sort()
# print(A)
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.util.Scanner;
public class Cards
{
public static void main(String args[])
{
int n;
Scanner sc = new Scanner(System.in);
int sum = 0;
n = sc.nextInt();
int array[] = new int[n];
int tp[] = new int[n];
for(int i=0;i<n;i++)
{
array[i] = sc.nextInt();
sum += array[i];
}
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... | public class Q5 {
public static void main(String[] args) {
java.util.Scanner input=new java.util.Scanner(System.in);
int sum, mid;
int[] a=new int[101];
int i, j;
int n=input.nextInt();
sum = 0;
for (i = 1; i <= n; i++){
a[i]=input.nextInt();
sum += a[i];
}
mid = sum * 2 / n;
for (i = ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import sys
import math
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 ().spl... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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;
vector<int> in;
vector<int> ans;
int main() {
ios::sync_with_stdio(false);
cin >> N;
in.resize(N);
ans.resize(N);
for (int i = 0; i < N; i++) ans[i] = -1;
int sum = 0;
for (int i = 0; i < N; i++) {
cin >> in[i];
sum += in[i];
}
int avg = 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()))
s = sum(a) // (n / 2)
t = -1
x =[]
for i in range(n + 1):
for j in range(i + 1, n):
if a[i] + a[j] == s and i not in x and j not in x:
print(i + 1, j + 1)
x.append(i)
x.append(j)
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
hm = [0]*200
l = list(map(int,input().split()))
s = int((sum(l)/n)*2)
ans = []
for i in l:
hm[i]+=1
for i in l:
if(hm[i]>0 and hm[s-i]>0):
x = l.index(i)+1
l[x-1] = -1
y = l.index(s-i)+1
l[y-1] = -1
hm[i]-=1
hm[s-i]-=1
ans.append((x,y))
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
x = (sum(a) * 2) // n
b = [False for i in range(n)]
for i in range(n):
if not b[i]:
for j in range(i + 1, n):
if not b[j]:
if a[i] + a[j] == x:
print(i + 1, j + 1)
b[i] = True
b[j] = True
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int a[(int)(305)], c[(int)(305)], n, kt[(int)(305)];
pair<long, long> b[(int)(305)][(int)(305)], res[(int)(305)];
void sol() {
memset(kt, 1, sizeof(kt));
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
c[a[i] + a[j]]++;
b[a[i] + a[j]][c... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | N = int(raw_input())
A = map(int, raw_input().split(' '))
A = zip(A, range(1,N+1))
A.sort()
only_indexes = [x[1] for x in A]
zipped = zip(only_indexes[:N/2], reversed(only_indexes[N/2:]))
for k,v in zipped:
print "{0} {1}".format(k,v)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
s = list(map(int,input().split()))
c=0
p=[s[0]]
for j in range(1,n):
if(s[j] not in p):
p.append(s[j])
else:
c+=0.00001
p.append(s[j]+c)
b = sorted(p)
for i in range(n//2):
print((p.index(b[i])+1),(p.index(b[n-1-i])+1))
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Cards {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = scan.nextInt();
}
int 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... | n = input()
n = int(n)
a = input().split()
vis = []
tol = 0
for i in range(n):
tol += int(a[i])
for i in range(n):
vis.append(0)
aver = tol//(n//2)
#print(aver)
for i in range(n) :
for j in range(n) :
if i <= j:
continue
if vis[i] == 0 and vis[j] == 0 :
if int(a[i]) +... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
import static java.lang.System.out;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
int[] cards = new int[n];
int inMin = 0;
int inMax = 1;
for (int 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int sum = 0, a[101];
for (int i = 0; i <= n - 1; i++) {
int x;
scanf("%d", &x);
a[i] = x;
sum += x;
}
int x = sum / (n / 2);
for (int i = 0; i <= n - 1; i++) {
for (int j = 0; j <= n - 1; j++) {
if... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | from operator import itemgetter
m = int(input())
lst=[int(i) for i in input().split()]
new = []
for i in range(1,m+1):
a,b = lst[i-1],i
pair = a,b
new.append(pair)
#print(new)
new.sort(key=itemgetter(0))
#print(new)
new1 = new[::-1]
#print(new1)
for i in range(0,int(m/2)):
print(new[i][1],new1[i][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | x = int(raw_input())
l = map(int, raw_input().split())
li2 =sorted([(l[i],i) for i in range(x)])
x=x/2
for i in range(x):
print li2[i][1]+1,li2[-1-i][1]+1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=input()
n=int(n)
x=[int(x) for x in input().split()]
f=int(sum(x)/(n/2))
sl=[0 for x in range(n)]
for y in range(n):
if sl[y]==1:
continue
sl[y]=1
for k in range(n):
if x[y]+ x[k]==f and sl[k]==0 :
sl[k]=1
print(y+1,end=" ")
print(k+1)
break
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
//SOLUTION BEGIN
//Into the Hardware Mode
void pre() throws Exception{}
void solve(int TC)throws Exception{
int n = ni();
int[] a = new int[n];
int sum = 0;
for(int i = 0; i< n; i++){
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
ar = list(map(int, input().split()))
total = sum(ar) // (n//2)
ans = []
num = 0
if n == 2:
print(1, 2)
else:
used_idxs = set()
for i in range(n):
if ar[i] == 0 or i in used_idxs:
continue
el = ar[i]
idx = len(ar) - ar[::-1].index(total-ar[i]) - 1
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.*;
import java.util.*;
public class A {
InputStream is;
int __t__ = 1;
int __f__ = 0;
int __FILE_DEBUG_FLAG__ = __f__;
String __DEBUG_FILE_NAME__ = "src/T";
FastScanner in;
PrintWriter out;
public void solve() {
int n = in.nextInt();
int[] a = in.nextIntArray(n);
int sum = 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... | #include <bits/stdc++.h>
using namespace std;
void solution();
int main() { solution(); }
void solution() {
int n;
vector<pair<int, int> > v;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
v.push_back(make_pair(x, i));
}
sort(v.begin(), v.end());
for (int i = 0; i < n / 2; 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>
int main() {
long int n, i, j, a[102], s = 0, d;
scanf("%ld", &n);
for (i = 0; i < n; i++) {
scanf("%ld", &a[i]);
s += a[i];
}
d = s / (n / 2);
if (n == 2)
printf("%ld %ld\n", 1, 2);
else {
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
if (i == ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import operator
n = int(input())
a = [int(s) for s in input().split(" ")]
asorted = sorted(enumerate(a), key=operator.itemgetter(1))
for i in range(n//2):
print(asorted[i][0]+1 , asorted[n-1-i][0]+1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<set<int> > nums;
nums.resize(101);
int n;
cin >> n;
int sum = 0;
for (int i = 0; i < n; i++) {
int t;
cin >> t;
nums[t].insert(i + 1);
sum += t;
}
sum = sum / (n / 2);
int pr = n / 2;
int idx = 1;
while (pr--) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | if __name__ == '__main__':
n = int(raw_input())
nums = [int(num) for num in raw_input().split()]
nums = sorted((num, i+1) for i, num in enumerate(nums)) # 1-based indexing
idxs = [i for num, i in nums]
for i in range(n/2):
print idxs[i], idxs[-(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())
l=list(map(int,input().split()))
a=max(l)+min(l)
d=0
p=[]
for i in range(n):
if(l[i]==0):
continue
q=l[i]
l[i]=0
c=l.index(a-q)
l[c]=0
if(i not in p and c not in p):
p.append(i)
p.append(c)
for i in range(1,len(p)+1):
if(i%2!=0):
print(p[i-1]+1,p[i]+1)
d+=1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
s = [int(i) for i in input().split()]
t = []
for i in range(n):
t.append((s[i], i+1))
r = (sum(s)//(n//2))
t.sort()
for i in range(n//2):
print(t[i][1], t[n-i-1][1])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
n = int(input())
num = input()
a = []
def get_the_data(count, num, arr):
for i in range(0, len(num)):
if num[i] == ' ':
arr.append(int(num[count:i]))
count = i+1
elif i == len(num)-1:
arr.append(int(num[count:len(num)]))
return arr
arr = get_the_data(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 swap(int &x, int &y) {
int t = x;
x = y;
y = t;
}
int main() {
map<int, int> m;
int n, t;
cin >> n;
vector<int> v(n);
int s = 0;
for (int i = 0; i < n; i++) {
cin >> v[i];
s += v[i];
}
s = s * 2 / v.size();
int x = 0;
for (int i = 0; i ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.ArrayList;
import java.util.Scanner;
public class Cards {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int input1 = reader.nextInt();
int jugadores = input1 / 2;
reader.nextLine();
String input2 = reader.nextLine();
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = [[a[i], i] for i in range(n)]
b.sort()
for i in range(n // 2):
print(b[i][1] + 1, b[n - i - 1][1] + 1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
b.append([a[i], i + 1])
b = sorted(b)
for i in range(n//2):
print(b[i][1], b[n-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | from __future__ import print_function
import sys#]
x = (int)(input())
a = []
q = []
i = 0
#while(i < x):
a = map(int,raw_input().split())
i = i + 1
#a.sort()
k = 1
z = []
for i in range(len(a)):
fu = (a[i], i + 1)
#print(fu)
z.append(fu)
l = 0
#print(z)
r = len(a) - 1
#z.sort(key=0)
z.sort()
#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... | import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeMap;
/**
* Created by yuu on 12/3/17.
*/
public class Problem701A {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
TreeMap<Integer, ArrayList<Integer>> map= new T... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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__ = 'Devesh Bajpai'
'''
https://codeforces.com/problemset/problem/701/A
Solution:
'''
def solve(n, arr):
arr_idx = list()
for i in xrange(0, n):
arr_idx.append([i+1, arr[i]])
arr_idx.sort(cmp=custom_compare)
for i in xrange(0, n/2):
print str(arr_idx[i][0]) + " " + str(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int n, a[1005], s, q, k = INT_MAX, kk = INT_MIN;
bool cx[1005];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
cx[i] = true;
k = min(k, a[i]);
kk = max(kk, a[i]);
}
q = k + kk;
if (n == 2)
cout << 1 << " " << 2;
else {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
bool used[100];
int main() {
int n;
cin >> n;
vector<int> a(n);
int s = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
s += a[i];
}
int cnt = s / (n / 2);
for (int i = 0; i < n; ++i) {
if (!used[i]) {
used[i] = true;
for (int j = 0; 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 = input()
n_str = raw_input()
slist = n_str.split()
sumn = 0
for i in range(n):
sumn += int(slist[i])
sumn = sumn*2/n
isV = [1 for i in range(n)]
for i in range(n):
if isV[i] == 1:
isV[i] = 0
for j in range(i,n):
if isV[j] == 1 and int(slist[i])+int(slist[j]) == sumn:
isV[j] = 0
print i+1,j+1
br... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()))
m=[]
for k in range (1,n+1):
aux=[a[k-1]]+[k]
m.append(aux)
nn=n//2
m.sort()
aux2=n-1
for j in range(nn):
print(m[j][1],m[aux2][1])
aux2-=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... |
get_int = lambda: map(int, input().split())
n = int(input())
h = list(get_int())
pts = sum(h) *2 / n
for i in h:
if i != 0:
a = h.index(i) + 1
h[h.index(i)] = 0
b = h.index(pts-i) + 1
h[h.index(pts - i)] = 0
print(a, b)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
t = list(zip(a, list(range(1, len(a) + 1))))
t.sort(key=lambda x: x[0])
for i in range(n // 2):
print(t[i][1], t[-i - 1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=[int(i) for i in input().split()]
d,b=dict(),[]
for i in range(n):
d[a[i]]=i+1
for i in a:
b.append(i)
b.sort()
#print(b)
#print(a[n-0])
for i in range(n//2):
p=a.index(b[i])
a[p]=-1
q=a.index(b[n-i-1])
a[q]=-1
print(p+1,q+1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import sys
def main():
reader = sys.stdin
n = int(next(reader))
cards = list(
enumerate(
map(int, next(reader).split()),
start=1
)
)
cards = sorted(cards, key=lambda card: card[1])
for i in range(n//2):
pr... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | dt=dict()
n=int(input())
nums=list(map(int,input().strip().split()))
for x in range(len(nums)):
dt[x+1] = nums[x]
ls=sorted(dt.values())
st,ed=0,len(ls)-1
kk = list(dt.keys())
vv = list(dt.values())
for x in range(int(len(ls)/2)):
a1=kk[vv.index(ls[st])]
vv[vv.index(ls[st])]=-2
a2=kk[vv.index(ls[ed])]
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
import java.io.*;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] nums = new int[n];
int total = 0;
for (int i = 0; i < n; i++) {
nums[i] = sc.nextInt();
total += nums[i];
}
int sum = total*2/n;
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... | n = int(input())
ls = list(map(int, input().split()))
sum = 2*sum(ls)//n
visited = {}
for i in range(1, n+1):
visited[i] = False
for i in range(1, n+1):
for j in range(1, n+1):
if visited[i] or visited[j] or i==j: pass
elif ls[i-1]+ls[j-1]==sum:
print(i, j)
visited[i] = T... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 answer():
targ = int(input())
a = [int(x) for x in input().split()]
targ=sum(a)/len(a)*2
i=0
paired=[]
while i<len(a):
#print(paired)
if i not in paired:
j=i+1
while j<len(a) and j!=i:
if j not in paired:
#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... | import java.util.Scanner;
public class Cards {
public static void main(String[]args) {
Scanner leer = new Scanner(System.in);
int cartas;
do {
cartas = leer.nextInt();
} while (cartas < 2 || cartas > 100 || cartas % 2 != 0);
int mazo[] = new int[cartas];
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;
public class probACon364 {
static class KV {
public KV(int k, int v){
key = k;
value = v;
}
public int key,value;
}
public static void main(String[] args) {
int n = 0 , sum = 0;
Scanner sc... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.IOException;
import java.util.*;
/**
* Created by kaaveh on 7/26/16.
*/
public class _701A_ {
public static void main(String[] args) {
kaaveh in = new kaaveh();
int num = in.kint();
int key;
int val;
ArrayList<obj> data = new ArrayList<obj>();
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>
struct bla {
int x;
int y;
};
bool cmp(struct bla a, struct bla b) { return a.x < b.x; }
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<struct bla> input(n);
for (int i = 0; i < n; i++) {
scanf("%d", &input[i].x);
input[i].y = i + 1;
}
sort(input.begin(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()))
each = sum(a)*2//n
used = [False for _ in range(n)]
for i in range(n):
if used[i]:
continue
for j in range(i+1,n):
if used[j]:
continue
if a[i]+a[j] == each:
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 num[105];
int main() {
ios::sync_with_stdio(false);
cin >> n;
int cnt = 0;
for (int i = 1; i <= n; i++) {
cin >> num[i];
cnt += num[i];
}
bool vis[105];
memset(vis, true, sizeof(vis));
cnt = cnt / (n / 2);
for (int i = 1; i <= n / 2; i++... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | N=int(input())
L=list(map(int,input().split()))
y=sum(L)
y=int(y/(N/2))
for i in range(N):
for j in range(i+1,N):
if(L[i]+L[j]==y):
L[i]=-10000
L[j]=-10000
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 = input()
nums = map(int, raw_input().split())
index = sorted(range(N), key=lambda x: nums[x])
a = 0
b = N - 1
for i in range(N / 2):
print index[a] + 1, index[b] + 1
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... |
n = int(input())
x = [int(x) for x in input().split()]
l = []
avg = sum(x) // (n // 2)
for i in range(n):
for j in range(n):
if x[i] + x[j] == avg:
if i not in l and j not in l and i != j:
l.append(i)
l.append(j)
print(i + 1 , j + 1) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
cards = list(map(int, input().split()))
used = [False] * n
total = 0
for card in cards:
total += card
m = total / (n/2)
for i in range(int(n/2)):
res = ""
for j in range(n):
if not used[j]:
used[j] = True
res += str(j+1)
res += " "
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
arr = [int(i) for i in input().split()]
for i in range(n):
arr[i] = (arr[i], i+1)
arr.sort(key=lambda x: x[0])
for i in range(n//2):
print(arr[i][1], arr[n-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
d = sum(a) // (n // 2)
used = [True] * n
ans = []
for i in range(n):
for j in range(i + 1, n):
if used[i] and used[j] and a[i] + a[j] == d:
used[i] = False
used[j] = False
ans.append((i + 1, j + 1))
for i in ans:
p... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = input()
a = [int(ai) for ai in raw_input().split(" ")]
b = [[a[i],i+1] for i in xrange(n)]
b.sort()
for i in range(n/2):
print b[i][1],b[n-i-1][1] |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
vector<int> arr[101];
cin >> n;
int sum = 0, temp;
for (int i = 1; i <= n; i++) {
cin >> temp;
arr[temp].push_back(i);
sum += temp;
}
sum = sum * 2 / n;
int ind = 1;
for (int i = 1; i < 101; i++) {
while (arr[i].size() >... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()))
used = list(False for x in range(n))
sred = (sum([x for x in arr]) * 2) // n
for i in range(n):
for j in range(n):
if i != j and arr[i] + arr[j] == sred and used[i] != True and used[j] != True:
print(i + 1, j + 1)
used[i] = use... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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=sum(l)//(n//2)
for i in range(n):
if l[i]=="*":
continue
for j in range(i+1,n):
if l[j]=='*':
continue
elif l[i]+l[j]==a:
print(i+1,j+1)
l[i]='*'
l[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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
bool b[n];
int max1 = 0, min1 = 101;
for (int i = 0; i < n; i++) {
cin >> a[i];
b[i] = true;
if (a[i] > max1) max1 = a[i];
if (a[i] < min1) min1 = a[i];
}
for (int i = 0; i < n; i++) {
for (int 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... | from sys import stdin
n = int(stdin.readline())
a = map(int, stdin.readline().split(' '))
sum = sum(a) * 2 / n
used = [False] * n
for i in range(n):
if used[i]:
continue
for j in range(i + 1, n):
if not used[j] and a[i] + a[j] == sum:
used[j] = True
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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class Cards {
void solve() {
int n = in.nextInt();
int[] a = new int[n];
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.util.*;
public class Main {
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] arr = new int[n];
int[] pos = new int[n];
for(int i=0;i<n;i++)
{
int a = s.nextInt();
arr[i] = 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... | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 14 12:46:45 2017
@author: admin
"""
n = int(input())
cards = [int(i) for i in input().split()]
solution=[]
new_cards = sorted(cards)
for i in range(n//2):
a = new_cards[i]
b = new_cards[n-i-1]
ai = cards.index(a)
cards[ai]=None
bi = cards.in... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
s=input().split()
for i in range(n):
s[i]=int(s[i])
l=sum(s)//(n//2)
k=sorted(s)
for i in range(n//2):
p=s.index(k[i])+1
s[s.index(k[i])]=-1
o=s.index(k[n-1-i])+1
s[s.index(k[n-1-i])]=-1
print(p,o)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | N = int(raw_input())
A = map(int, raw_input().split())
k = []
for i in xrange(N):
k.append((A[i], i + 1))
k.sort()
for i in xrange(N / 2):
print k[i][1], k[N - i - 1][1]
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = []
l = list(map(int, input().split()))
for i in range(len(l)-1):
for j in range(i+1, len(l)):
if l[i] + l[j] == sum(l)//(n//2):
if i+1 not in a and j+1 not in a:
a.append(i+1)
a.append(j+1)
break
i = 0
while i<len(a):
prin... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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_Relados {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a[] = new int[n];
boolean flag[] = new boolean[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... | def swap(seq,i,j):
temp=seq[i]
seq[i]=seq[j]
seq[j]=temp
def argsort(n,seq):
i=1
indices=[]
while i<=n:
indices.append(i)
i+=1
i=0
while i<n-1:
j=i+1
while j<n:
if(seq[j]<seq[i]):
swap(seq,i,j)
swap(indices,i,j)
j+=1
i+=1
return indices
def Cards(n, seq):
argSorted= argsort(n,seq)
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
a=[int(i) for i in input().split(" ")]
norm=int(2*sum(a)/n)
for i in range(n):
if a[i]!=0:
for j in range(n):
if a[i]+a[j]==norm and i!=j:
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a;
cin >> n;
vector<pair<int, int> > p;
for (int i = 0; i < n; i++) {
cin >> a;
p.push_back({a, i});
}
sort(p.begin(), p.end());
for (int j = 0; j < n / 2; j++) {
cout << p[j].second + 1 << " " << p[n - 1 - j].second + 1 << endl... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
int main() {
int n, a[101], i, j, sum = 0, k, a2[101];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum = sum + a[i];
}
k = sum / (n / 2);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
if (i != j && a[i] + a[j] == k) {
printf("%d %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())
list1=list(map(int,input().split(" ")))
w=sum(list1)//(n>>1)
for j in range(n):
if list1[j]!=None:
q=list1[j]
list1[j]=None
p=list1.index(w-q)+1
print(j+1,p)
list1[p-1]=None
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 [] arg)
{
Scanner sc = new Scanner (System.in);
int n = sc.nextInt();
int [] card = new int[n];
int sum =0;
for (int i=0;i<n;i++)
{
card[i] = sc.nextInt();
sum =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... | t=1
while t:
t-=1
n=input()
a=[int(x) for x in raw_input().split()]
s=(sum(a)*2)/n
h=[0]*n
for x in range(0,n):
if h[x]==0:
for y in range(x+1,n):
if a[x]+a[y]==s and h[y]==0:
h[x]=1
h[y]=1
print(x+1),
print(y+1)
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, arr[10001], i, j, sum = 0;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> arr[i];
sum += arr[i];
}
int x = sum / (n / 2);
for (i = 1; i < n; i++) {
if (arr[i]) {
for (j = i + 1; j <= n; j++) {
if (arr[i] + arr[j] == 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 java.util.*;
public class Main{
public static void main(String []args){
Scanner s=new Scanner(System.in);
HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
int n=s.nextInt();
Pair a[]=new Pair[n];
for(int i=0;i<n;i++){
a[i]=new Pair(s.nextInt(),i+1);
}
Arrays.sort(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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,n+1)))
for i in range(n//2):
print(l[i][1], l[-1-i][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.*;
import java.util.*;
public class Main
{
public static void main(String args[]) throws IOException
{
int temp=0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
int n = Integer.parseInt(str);
str = br.readLine();
String myarr[] = str.split(" ");
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... | import java.util.Scanner;
import java.util.ArrayList;
public class Cards {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int total = 0;
int[] cards = new int[n];
ArrayList<Integer> used = new ArrayList<Integer>();
for (int i = 0; i< n; i++) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Task701A {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int nCards = input.nextInt();
int[] sums = new int[nCards];
for (int i = 0; i < nCards; i++) {
int card = input.nextInt();
sums[i] = card;
}
int sum = 0;
for (int 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... | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
n = int(input())
a = list(map(int, input().split()))
avg = int((sum(a)*2)/n)
c = 0
i = 0
while(c<n/2):
if a[i]==-1:
i = i + 1
else:
temp1 = avg - a[i]
a[i] = -1
temp2 = a.index(temp1)
print(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())
vec = list(map(int, input().split()))
ans = list()
for i in range(n) :
tmp_list = list()
tmp_list.append(vec[i])
tmp_list.append(i+1)
ans.append(tmp_list)
ans = sorted(ans)
for i in range(n//2):
print(ans[i][1] , ans[-(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... | //package edu.vn.haui.leson;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import ja... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 P701A
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] arr = new int[n];
int sum = 0;
for (int i = 0; i < n; i++)
sum += arr[i] = scan.nextInt();
int each = sum*2 / n;
for (int i = 0; i < n; i++)
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
arr = [int(x) for x in input().split()]
t = zip(arr, range(1, n+1))
t = sorted(t)
for i in range(len(t)//2):
print(t[i][1], t[n-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cv=new Scanner(System.in);
int n=cv.nextInt();
int arr[]=new int[n];
int sum1=0;
for (int i = 0; i < n ; i++) {
arr[i]=cv.nextInt();
sum1+=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... |
import java.util.*;
import java.util.*; import java.lang.*; import java.io.*;
public class s{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int ar[] = new int[n];
int s=0;
for(int i = 0;i<n;i++){
ar[i] ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=[int(i) for i in input().split()]
s=0
for i in a:
s+=i
s//=(n//2)
for i in range(n):
for j in range(n):
if a[i]+a[j]==s and i!=j and a[i]!=-1 and a[j]!=-1:
print(i+1, j+1)
a[i], a[j]=-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.util.Scanner;
public class Main {
public static void main (String args[])
{
Scanner sc = new Scanner (System.in);
int n = sc.nextInt();
int sum=0;
int arr[] = new int[n];
for(int i=0;i<n;i++)
{
arr[i] = sc.nextInt();
}
int min = arr[0];
int max= arr[n-1];
for(int i=0;i<n;i++)
{
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() {
int n;
cin >> n;
vector<int> v(n);
int sum = 0;
multimap<int, int> m;
for (int i = 0; i < n; i++) {
cin >> v[i];
sum += v[i];
m.emplace(make_pair(v[i], i + 1));
}
multimap<int, int>::iterator left = m.begin();
multimap<int, int>::i... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #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 - 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... | #include <bits/stdc++.h>
using namespace std;
long long int n;
vector<pair<long long int, long long int> > my;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t;
cin >> n;
for (long long int i = 0; i <= n - 1; i++) {
cin >> t;
my.push_back(make_pair(t, i + 1));
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.