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... | #include <bits/stdc++.h>
const double pi = (double)(2.0 * acos(0.0));
const int inf = 1 << 30;
const double eps = 1E-9;
const double e = exp(1.0);
const int sz = 100000 + 5;
const int mod = 1000000000 + 7;
using namespace std;
bool vis[101];
int a[101];
int main() {
int n;
int tt = 0, i, j;
memset(vis, 0, sizeof(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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, b = input(), []
a = map(int, raw_input().split())
for i in range(n):b.append([a[i], i + 1])
b.sort()
for i in range(n/2):
print b[i][1], 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... | #!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
n = int(input())
a = sorted([(int(x), i) for i, x in enumerate(input().split(), start=1)])
for i in range(n // 2):
print(a[i][1], a[-i-1][1])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #https://codeforces.com/problemset/problem/701/A
#Feel pain, think about pain, accept pain, know pain...
n=int(input())
a=map(int, raw_input().split())
b=[]
for i in range(n):
b.append([a[i],i+1])
b.sort()
for i in range(n/2):
print b[i][1], 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, i, j, b[1000], sum = 0;
cin >> a;
for (i = 1; i <= a; i++) {
cin >> b[i];
sum += b[i];
}
sum = sum / (a / 2);
for (i = 1; i <= a; i++) {
for (j = 1; j <= a; j++) {
if (b[i] != 1000 && b[j] != 1000 && i != j) {
if (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())
l=list(map(int,input().split()))
value=int(sum(l) / (n/2))
for i in range(n):
if (l[i] != -1):
j = l[i]
l[i] = -1
print (str((i+1)) + ' ' + str((l.index((value - j)) + 1)))
l[l.index(value - j)] = -1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
l=[int(x) for x in input().split()]
v=(sum(l)*2)//n
was=[]
for i in range(n):
if not i in was:
tmp=v-l[i]
for j in range(i+1,n):
if l[j]==tmp and not j in was:
was.append(j)
print(i+1,j+1)
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | # import os
n = int(input())
a = list(map(int, input().split()))
aa = sorted(a)
s = aa[0] + aa[-1]
index = []
i = 0
while a:
if a[i] == -1:
i += 1
else:
to_find = s - a[i]
ind = a.index(a[i])
index.append(ind+1)
a[i] = -1
ind2 = a.index(to_find)
inde... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n, a = int(input()), sorted((int(x), i + 1) for i, x in enumerate(input().split()))
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... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
struct Node {
int point;
int data;
} nod[maxn];
bool cmp(struct Node a, struct Node b) { return a.data < b.data; }
int main() {
int n;
while (cin >> n) {
for (int i = 0; i < n; i++) {
cin >> nod[i].data;
nod[i].point = 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 a[101][2];
int main() {
int n;
cin >> n;
double sum = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i][0];
sum += a[i][0];
}
sum = (sum / n) * 2;
for (int i = 1; i <= n; i++) {
if (a[i][1] == 0) {
cout << i << " ";
for (int j = i + 1; ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | from collections import defaultdict, Counter
def solve(arr, n):
d = defaultdict(list)
c = Counter(arr)
st = set()
for index, value in enumerate(arr):
d[value].append(index + 1)
m = 2 * sum(arr) // n
for x in arr:
if c[x]:
if x == m - x:
print(d[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... | n = int(input())
al = list(map(int,input().split()))
for i in range(n):
al[i]=[al[i],i+1]
al.sort()
for i in range(n//2):
print(al[i][1],al[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... | if __name__ == '__main__':
n = int(input())
aa = map(int, input().split())
aa = sorted(enumerate(aa), key=lambda x: x[1])
for i in range(n // 2):
print(f'{aa[i][0] + 1} {aa[n - i - 1][0] + 1}')
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int a[n], b[n];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
b[i] = i + 1;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i; j++) {
if (a[j] > a[j + 1]) {
swap(a[j], a[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... | s = int(input())
o = input()
seq = [int(x) for x in o.split()]
seq = sorted(seq)
turn = (s//2)
ans = []
for x in range(turn):
ans.append([seq[-1],seq[0]])
seq.pop(0)
seq.pop(-1)
o = o.split()
num = [x for x in range(1,s+1)]
zipped = {a:b for a,b in zip(num,o)}
final = []
f = ""
for y in ans:
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
vector<int> a;
bool tag[110];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int sum = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
sum += x;
a.push_back(x);
}
sum /= (n / 2);
for (int i = 0; i < n; i++) {
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() {
bool f, s;
int n, x;
cin >> n;
int order[n], cards[n];
for (int i = 0; i < n; i++) {
cin >> order[i];
cards[i] = order[i];
}
sort(cards, cards + n);
for (int i = 0, j = n - 1; i < n / 2; i++, j--) {
x = 0;
f = false;
s = fals... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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)
l1=[]
for i in range(n):
for j in range(i+1,n):
if l[i]+l[j]==a:
if i+1 not in l1 and j+1 not in l1:
l1.append(i+1)
l1.append(j+1)
break
for i in range(0,n-1,2):
print(l1[i],l1[i+1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | /**
* Created by Omar on 7/22/2016.
*/
import java.util.*;
import java.io.*;
public class CF364A {
public static int[]a;
public static int[] b;
public static int n;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(Syst... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = input()
lists = map(int,sys.stdin.readline().split())
avg , has , idx = sum(lists) / (n/2) , [0]*101 , [[] for i in range(101)]
for j,i in enumerate(lists) :
has[i] += 1
idx[i].append(j)
count , i , mark = 0 , 0 , [0]*101
while i < n and count < n :
if not mark[i] :
if has[abs(lists... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #!/usr/bin/env python
#-*-coding:utf-8 -*-
M=tuple([]for i in range(100))
s=0
n=int(input())>>1
for i,e in enumerate(map(int,input().split())):
e-=1
s+=e
M[e].append(1+i)
s//=n
for i,e in enumerate(M):
while e:
n-=1
print(e.pop(),M[s-i].pop())
if not n: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())
arr = [int(x) for x in input().split()]
s = min(arr) + max(arr)
for i in range(n):
if arr[i] != -1:
for j in range(i + 1, n):
if arr[j] != -1:
if arr[i] + arr[j] == s:
print(i + 1, j + 1)
arr[i], arr[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... | a=int(input())
b=input().split()
s=0
c=[]
if a!=2:
for i in range(a):
s+=int(b[i])
s=s*2//a
for i in range(a):
if b[i]!='a':
v=b[i]
b[i]='a'
d=b.index(str(s-int(v)))
c.append(i+1)
c.append(d+1)
b[d]='a'
for i in rang... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()))
ls=sorted((l[i],i+1) for i in range(n))
ans=[]
for i in range(n//2):
ans+=[' '.join([str(ls[i][1]),str(ls[n-i-1][1])])]
print('\n'.join(ans)) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
T BigMod(T b, T p, T m) {
if (p == 0) return 1;
if (p % 2 == 0) {
T s = BigMod(b, p / 2, m);
return ((s % m) * (s % m)) % m;
}
return ((b % m) * (BigMod(b, p - 1, m) % m)) % m;
}
template <typename T>
T POW(T B, T P) {
if (P == 0) ret... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 sum, n, a[200];
scanf("%d", &n);
sum = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
sum /= (n / 2);
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++)
if (a[j] >= 1 && 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 = []
j = 1
for i in input().split():
a.append([int(i), j])
j+=1
a.sort()
for i in range(n//2):
print(a[i][1], a[-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.BigDecimal;
import java.math.BigInteger;
public class JavaApplication9 {
//******************************************************************... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
xt = []
for i, it in enumerate(a):
xt.append((i+1, it))
xt = sorted(xt,key=lambda w: w[1])
for i in xrange(n/2):
print xt[i][0], xt[-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... | #include <bits/stdc++.h>
using namespace std;
using lint = long long int;
int main() {
lint n;
cin >> n;
vector<lint> v(n);
for (lint i = 0; i < n; i++) {
cin >> v[i];
}
lint val = 2 * accumulate(v.begin(), v.end(), 0ll) / n;
vector<lint> visited(n);
for (lint i = 0; i < n; i++) {
if (visited[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... | l=lambda:map(int,raw_input().split())
n=input()
s=sorted(enumerate(l(),1),key=lambda (a,b):b)
for i in range(n/2):
print s[i][0],s[-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())
cards = sorted((a, i) for i, a in enumerate(map(int, input().split()), 1))
for i in range(n // 2):
print(cards[i][1], cards[- 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... | # Cards
def get_result(a, n):
p = n/2
s = sum(a) / p
it = 0
selected = set()
result = []
for i in range(p):
while it in selected:
it += 1
ik = it + 1
while ik in selected or a[it] + a[ik] != s:
ik += 1
selected.add(it)
selected.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;
const int maxn = 1e2 + 111;
const int eps = 1e-9;
const int inf = 1e9;
int n;
pair<int, int> a[maxn];
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i].first;
a[i].second = i;
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i += 2) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=input()
a=map(int,raw_input().split())
b = range(1, n+1)
b = sorted(b, key=lambda x:a[x-1])
a.sort()
for i in range(n/2):
print b[i], b[-i-1] |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
a_half = sum(a) * 2 // n
for i in range(n- 1):
for j in range(i + 1, n):
if a[i] + a[j] == a_half:
print(i + 1, j + 1)
a[i] = 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... | n = int(input())
a = []
j = 1
for i in input().split():
a.append([int(i), j])
j+=1
a.sort()
#print(*a)
for i in range(n//2):
print(a[i][1], a[-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def Solve(n, a):
answer = []
need = sum(a)
need /= (n / 2)
s = set()
for i in range(n):
if i in s:
continue
for j in range(n):
if i == j or j in s:
continue
if a[i] + a[j] == need:
answer.append([i + 1, j + 1])
s.add(i)
s.add(j)
break
return answer
n = int(raw_input())
a = map(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... | if __name__ == '__main__':
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
target = 2*total//n
for i in range(n):
if a[i] is None:
continue
first = a[i]
a[i] = None
for j in range(i+1, n):
if a[j] is None:
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... | /**
* Created by sanjayyepuri on 8/20/16.
*/
import java.util.*;
import java.io.*;
public class A {
static class Pair implements Comparable<Pair>{
int a, b;
public Pair(int a, int b){
this.a = a;
this.b = b;
}
public int compareTo(Pair x){
ret... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 statistics import mean
n = int(input())
c = list(map(int, input().split()))
t = mean(c) * 2
for i in range(len(c)):
if c[i] == 0:
continue
for j in range(len(c)):
if i == j:
continue
if c[j] == 0:
continue
if c[i] + c[j] == t:
print(i + 1... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
x = list(map(int, input().split()))
s = sum(x)
k = set()
for i in range(n):
for j in range(i+1, n):
if x[i] + x[j] == s // (n//2):
if i in k or j in k:
continue
else:
k.add(i)
k.add(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... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int n, in;
pair<int, int> a[100];
cin >> n;
for (int i(0); i < n; ++i) {
cin >> in;
a[i] = make_pair(in, i + 1);
}
sort(a, a + n);
for (int i(0); i < n / 2; ++i)
cout << a[i].second << ' ' << a[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... | #!/usr/bin/python
n = int(raw_input())
arr = map(int, raw_input().strip().split(" "))
reqSum = sum(arr)/(n/2)
visited = [False]*n
for i in range(n):
if visited[i]==False:
visited[i]=True
first = i+1
temp = i+1
req = reqSum-arr[i]
while temp<n:
if visited[temp]==False:
if arr[temp]==req:
visite... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = input
p = print
r = range
n = int(t())
a = list(map(int, t().split()))
ma = max(a)
mi = min(a)
su = mi + ma
for i in range(n):
if a[i] == -1:
continue
else:
for j in range(n):
if a[i] + a[j] == su and i != j:
p(i + 1, j + 1)
a[i] = -1
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
arr = [0] * 201
counter = 1
for i in range(201):
arr[int(i)] = list()
for i in input().split():
arr[int(i)].append(counter)
counter = counter + 1
for i in range(2,201):
rpta = list()
cnt = 0
val = i//2 + 1 if i % 2 == 1 else i//2
for j in range(val):
if len(arr[j])... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
numbers= [int(i) for i in input().split()]
indexes = sorted(range(1, n+1), key=lambda i: numbers[i-1])
for i in range(n//2):
print(indexes[i], indexes.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... | /*input
4
1 2 3 4
*/
import java.io.*;
import java.util.*;
public class Main {
public static void main(String []args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int n = Integer.parseInt(line);
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=list(map(int,input().split()))
s=0
for i in a:
s=s+i
total=int((s/n)*2)
for i in range(0,len(a)):
if(a[i]!=0):
for j in range(0,len(a)):
if(a[i]+a[j]==total and i!=j):
print(i+1,j+1)
a[i]=0
a[j]=0 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
k = n // 2
a = [int(i) for i in input().split()]
s = sum(a) // k
d = dict()
c = 0
for i, e in enumerate(a):
d[e] = d.get(e, [])
d[e].append(i + 1)
for i in sorted(d.keys()):
while d[i] != []:
print(d[i].pop(), d[s - i].pop())
c += 1
if c >= k: break
if c >= k: 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... | a = int(input())
l = list(map(int, input().split()))
x = sum(l)//(a//2)
g = []
for i in range(a):
k = []
if l[i] != 0:
k.append(i+1)
t = l[i]
l[i] = 0
k.append(l.index(x-t)+1)
l[l.index(x-t)] = 0
g.append(k)
for j in range(len(g)):
print(g[j][0], g[j][1])
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = sorted([(x, i + 1) for (i, x) in enumerate(map(int, raw_input().split(' ')))])
l = 0
r = len(a) - 1
while l < r:
print a[l][1], a[r][1]
l += 1
r -= 1 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int number;
cin >> number;
int arr[number][2];
for (int i = 0; i < number; i++) {
cin >> arr[i][0];
arr[i][1] = i + 1;
}
for (int i = 0; i < number; i++) {
for (int j = i; j < number; j++) {
if (arr[i][0] > arr[j][0]) {
swa... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
l=list(map(int,input().split()))
x=(sum(l)//(n//2))
for i in range(n):
if l[i] != 0:
z=l[i]
l[i]=0
print(i+1,l.index(x-z)+1)
l[l.index(x-z)]=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()))
a = []
for i in range(n):
a.append([l[i],i+1])
a.sort()
for i in range(n//2):
print(a[i][1],a[n-1-i][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
const int E = 1e5 + 5;
pair<int, int> p[105];
long long a, b[105], c[105], d, e, f, g, h, i, j, k, l, m, n, o, q, r, x, y, z;
string s, t, u, v, w;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> a;
for (int q = 0; q < a; q++) {
cin ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())//2
a = [int(s) for s in input().split()]
s=0
for i in a:
s+=i
sr_s = s // n
for i in range(len(a)-1):
for j in range(i+1,len(a),1):
if (a[j] != -1) and (a[i]+a[j] == sr_s):
print(i+1,j+1)
a[i]=-1
a[j]=-1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int, input().split()))
s = sum(l) // (n // 2)
for i in range(n):
if l[i] != 0:
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... | n=int(input())
t=list(map(int,input().split()))
minl=1000000000
maxl=-1
for i in t :
minl=min(minl,i)
maxl=max(maxl,i)
add=minl+maxl
li=[[]for i in range(105)]
for i in range(n) :
if len(li[add-t[i]])>0 :
print(li[add-t[i]][-1],i+1)
li[add-t[i]].pop()
else :
li[t[i]].append(i+1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def key(a):
return a[0]
def main():
count = int(input())
card=list()
r=input().split()
for i in range(count):
card.append([int(r[i]), i+1])
card.sort(key=key)
for i in range(count//2):
print(str(card[i][1])+' '+str(card[-1*i-1][1]))
main() |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
cards = list(map(int, input().split()))
points = sum(cards) // (n // 2)
card_dict = {}
for i in range(n):
card_dict[cards[i]] = card_dict.get(cards[i], [1])
card_dict[cards[i]].append(i + 1)
cards.sort()
for i in range(n // 2):
print(card_dict[cards[i]][card_dict[cards[i]][0]], 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... | /*-
* Codeforces problem :
* http://codeforces.com/problemset/problem/701/A
*
* Print n / 2 pairs of integers, the i-th pair denote
* the cards that should be given to the i-th player.
* Each card should be given to exactly one player.
* Cards are numbered in the order they appear in the input.
* It is guarante... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = 1, k, l, j, i, s = 0;
int a[101], b[101];
cin >> k;
for (i = 1; i <= k; i++) {
cin >> a[i];
l = a[1];
if (a[i] != l) n = 0;
s += a[i];
}
for (i = 1; i <= k; i++) {
for (j = i + 1; j <= k; j++) {
if (a[i] + a[j] == s... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int,input().split()));s = []
for i in range(n):
s.append([l[i],i+1])
s.sort()
for i in range(n//2):
print(s[i][1], s[-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()))
b = 0
a = sorted([(int(a[i]),i + 1) for i in range(n)])
for i in range(0,len(a) // 2):
print(a[i][1],a[-i - 1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = n * [0]
i = 0
x = list(map(int, input().split()))
while i != n:
for j in range(i + 1, n):
if x[i] + x[j] == 2 * sum(x) // n and a[i] == 0 and a[j] == 0:
a[i] = x[i]
a[j] = x[j]
print(i + 1, j + 1)
break
i += 1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
if i in b:
continue
else:
print(i+1, end = ' ')
b.append(i)
for j in range(i+1, n):
if a[j]+a[i]==sum(a)//(n//2) and j not in b:
print(j+1)
b.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.*;
import java.io.*;
public class Main {
static String[] I=new String[101];
static int[] A=new int[102];
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i=1;i<=100;i++)
{
I[i]="";
}
for(int i=1;i<=n;i++)
{
A[i]=sc.nex... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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
# sys.stdin = open("test.in","r")
# sys.stdout = open("test.out","w")
n=int(input())
a=list(map(int,input().split()))
b=sum(a)/(n/2)
for i in range(n):
for j in range(i+1,n):
if a[i]+a[j]==b:
print(i+1,j+1)
a[j]=0
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
pair<int, int> a[n];
for (i = 0; i < n; i++) {
cin >> a[i].first;
a[i].second = i + 1;
}
sort(a, a + n);
for (i = 0; i < n / 2; i++)
cout << a[i].second << " " << a[n - i - 1].second << "\n";
}
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
minimum = 101
maximum = 0
pairs = 0
i = 0
for m in range(n):
minimum = min(minimum, a[m])
maximum = max(maximum, a[m])
while pairs < (n // 2):
if a[i] != 0:
print(i + 1, a.index(minimum + maximum - a[i], i + 1, n) + 1)
a[a.index(minimum + maximum - a[i], 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... | input()
maps = {}
ar = list(map(int, input().split()))
each = sum(ar) // (len(ar) // 2)
for i in range(len(ar)):
if ar[i] not in maps:
maps[ar[i]] = [i + 1]
else:
maps[ar[i]] += [i + 1]
for m in maps:
if maps[m]:
if m != each - m:
x1 = maps[m]
x2 = maps[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... | import java.util.*;
public class Tester {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int total=scan.nextInt();
int[] series=new int[total];
int[][] result=new int[total][2];
int sum=0;
for(int i=0;i<total;i++){
series[i]=scan.nextInt();
sum=sum+series[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... | n = int(raw_input())
a = map(int,raw_input().split())
s = max(a) + min(a)
l = []
for i in xrange(0,n):
for j in xrange(1,n):
if s - a[i] == a[j] and not(i in l) and not(j in l) and i !=j:
l.append(i)
l.append(j)
print i+1,j+1
#print 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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Cards {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
String s[]=br.readLine().split(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | /**
* Created by stem on 01.05.2016.
*/
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String args[]) throws IOException {
Scanner sc = new Scanner(System.in);
byte[][] a = new byte[sc.nextByte()][2];
for (byte i = 0; i < a.length; 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
f = sys.stdin
num_cards = int(f.readline())
cards = [int(card) for card in f.readline().split()]
pair_sum = sum(cards) / (num_cards / 2)
card_dict = {}
for index, card in enumerate(cards):
if card not in card_dict:
card_dict[card] = {index}
else:
card_dict[card].add(index)
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
l=list(map(int,input().split()))
a=sorted(l)
for i in range(n//2):
c=l.index(a[i])
l[c]=-1
d=l.index(a[n-1-i])
l[d]=-1
print(c+1,d+1) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input());d=sorted(zip(map(int,input().split()),range(1,n+1)))
for i in range(n//2):print(d[i][1],d[-i-1][1])
# Made By Mostafa_Khaled |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def main():
n = int(input())
cards = [0] + [int(_) for _ in input().split()]
total_points = sum(cards)
player_points = total_points // (n // 2)
marked = [False] * (n + 1)
count = 0
for i in range(1, n):
if marked[i]:
continue
searched_value = player_points - car... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWri... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | a = int(input())
b = list(map(int, input().split()))
summ = 0
c = {}
d = {}
for i in range(a):
summ += b[i]
c[i] = 1
d[b[i]] = i + 1
summ /= a / 2
for i in range(a):
for j in range(a):
if c[i] != 0 and c[j] != 0 and b[i] + b[j] == summ and i != j:
c[i] = 0
c[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())
a = list(map(int, input().split()))
l = []
for i in range(len(a)):
l.append((i + 1, a[i]))
l.sort(key=lambda x: x[1])
for i in range(n//2):
print(l[i][0], 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... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x=sc.nextInt();
int[] arr=new int[x];
int sum=0;
for(int i=0;i<x;i++) {
arr[i]=sc.nextInt();
sum+=arr[i];
}
sum=(sum*2)/x;
for(int i=0;i<x;i++) {
if(arr[i]!=-1) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int n;
int main() {
cin >> n;
vector<int> a(n);
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
sum /= n / 2;
for (int i = 0; i < n; i++)
if (a[i] > 0)
for (int j = i + 1; j < n; 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... | import java.util.Scanner;
public class Main {
static Scanner scanner;
public static void main(String[] args){
scanner=new Scanner(System.in);
int n=scanner.nextInt();
int[] array = new int[n];
boolean[] free = new boolean[n];
int sum=0;
for(int i=0;i<n;i++){
array[i]=scanner.nextInt();
free[i]=true... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
s = sum(a) // (n // 2)
used = [False for i in range(n)]
for i in range(n):
if used[i]:
continue
used[i] = True
for j in range(i + 1, n):
if used[j]:
continue
if a[i] + a[j] == s:
used[j] = True
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 = int(input())
a = list(map(int,input().split()))
s = []
for i in range(0,len(a)):
s.append((i+1,a[i]))
def getkey(item):
return item[1]
l = sorted(s,key = getkey)
i = 0
j = len(l)-1
while i<j:
print(l[i][0]," ",l[j][0])
i += 1
j -= 1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
//import javax.swing.JButton;
//import javax.swing.JLabel;
//import javax.swing.JTextFi... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()
c = map(int, raw_input().split())
avg = sum(c)/(n/2)
for i in xrange(n/2):
c1 = [i for i in xrange(n) if c[i]!=0][0]
c2 = c.index(avg-c[c1], c1+1)
c[c1] = c[c2] = 0
print c1+1, c2+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 = max(a) + min(a)
for i in xrange(n):
for j in xrange(i+1,n):
if a[j] !=0:
if a[i] + a[j] == s:
print i+1 , j+1
a[i] = 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... | 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-1-i][1] )
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int,input().split()))
a = []
j = 1
for i in range(n):
a.append([l[i] , j])
j +=1
a.sort()
#print(a)
for i in range(n//2):
print(a[i][1] , a[-i - 1 ][1])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
s = map(int, raw_input().split())
total = 0
for i in s:
total += i
p = (total*2)/n
for i in range(n):
for j in range(i+1, n):
if s[i]+s[j] == p:
print i+1, j+1
s[i] = 0
s[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... | a=int(input())
l=[int(t)for t in input().split()]
for i in range (len(l)):
l[i]=[l[i],i+1]
l.sort()
#print (l)
for i in range (a//2):
print (str(l[i][-1])+" "+str(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 ACards {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String[] ai = br.readLine().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... | n = int(input())
lis = [int(x) for x in input().split(' ')]
lis1 = sorted(lis)
j = 0
for i in range(n // 2):
x = lis.index(lis1[j])
lis[x] = 0
print(x + 1, end = " ")
x = lis.index(lis1[n - 1 - j])
lis[x] = 0
print(x + 1, end = " ")
j = j + 1
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... | #include <bits/stdc++.h>
using namespace std;
int n;
struct mang {
int x, vt;
} a[105];
bool cmp(mang p, mang q) { return p.x < q.x; }
int main() {
ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].x;
a[i].vt = i;
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <=... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 Tren1 {
public static void main(String[] args){
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int mas[]=new int[n];
ArrayList<Integer> ar=new ArrayList<>();
int sum=0;
for(int i=0;i<n;i++){
mas[i]=scn.nextInt();
sum+=mas[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.