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... | f=lambda:map(int,input().split())
n=int(input())
l=sorted(zip(f(),range(1,1+n)))
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... | n = int(input())
a = list(map(int, input().split()))
u = [False] * n
s = sum(a) // (n // 2)
rf = []
rs = []
for i in range(n):
if (u[i]):
continue
f = a[i]
u[i]=True
sec = s - f
fi = i
si = 0
for j in range(n):
if (u[j]):
continue
if (a[j] == sec):
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = sorted([ (int(val), ind + 1) \
for (ind, val) in enumerate( input().split() ) ])
for i in range(n//2):
print(numbers[i][1], numbers[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... | x = int(input())
lista = list(map(int, input().split()))
listaux = [0]*x
for i in range(x-1):
for j in range(i+1,x,1):
if(lista[i]+lista[j] == sum(lista)/(x/2) and listaux[j] == 0 and listaux[i] == 0):
print(i+1, j+1)
listaux[i] = 1
listaux[j] = 1
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int,input().split()))
ans = ""
h = max(l) + min(l)
for f1 in range(n-1):
for f2 in range(f1+1,n):
if l[f1] + l[f2] == h :
ans += str(f1+1)+" "+str(f2+1)+"\n"
l[f1] = 0
l[f2] = 0
break
print(ans.strip())
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 arr[101];
bool chk[101];
int main() {
int sum = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
sum += arr[i];
}
sum /= (n / 2);
for (int i = 0; i < n - 1; i++) {
if (chk[i] == true) continue;
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[105], sum = 0, i, j, x, k;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
x = sum / (n / 2);
for (j = 0; j < n; j++) {
for (k = j + 1; k < n; k++) {
if (a[j] + a[k] == x) {
printf("%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())
a=list(map(int,input().split()))
p=sum(a)*2//n
for i in range(n):
for j in range(n):
if i!=j and a[i]+a[j]==p:print(i+1,j+1);a[j]=a[i]=0 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int,input().split()))
avr = 2*sum(a)//n
for i in range (n):
if(a[i]!=0):
print(i+1,end=' ')
for j in range (n):
if(a[i] + a[j] == avr and i!=j):
print(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())
cards = sorted([(y, x+1) for x, y in enumerate(map(int, input().split()))])
half = len(cards) // 2
for (a, ia), (b, ib) in zip(cards[:half], reversed(cards[half:])):
print(ia, ib)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
t = list(map(int, input().split()))
a = []
for i in range(n): a.append([t[i],i+1])
a.sort()
for i in range(n // 2): print(a[i][1], a[-i - 1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int,input().split()))
s = sum(l)//(n//2)
d = {}
for i in range(1,101):
d[i]=[]
for i,j in enumerate(l):
d[j].append(i+1)
for i in range(1,101):
while len(d[i])!=0:
print(d[i][0],end=' ')
d[i]=d[i][1:]
print(d[s-i][0])
d[s-i]=d[s-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())
list=[int(i) for i in input().split()]
temp=list.copy()
temp.sort()
for i in range(int(n/2)):
for j in range(0,n):
if(temp[i]==list[j]):
list[j]=-1
break
print(j+1,end=" ")
for j in range(0,n):
if(temp[n-1-i]==list[j]):
list[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())
a = list(enumerate(map(int, input().split())))
a.sort(key=lambda x: x[1])
for i in range(n // 2):
p = a[i]
q = a[-i - 1]
print(p[0] + 1, q[0] + 1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Arrays.f... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
val = list(map(int, input().split()))
vis = [0] * n
tot = sum(val) // (n // 2)
for i in range(n):
if vis[i] == 1: continue
vis[i] = 1
for j in range(i + 1, n):
if vis[j] == 0 and val[j] + val[i] == tot:
print(i + 1, j + 1)
vis[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... | # IT-programmer
n = int(input())
v = n
N = n // 2
x = list(map(int, input().split()))
avg = sum(x) // N
for i in range(len(x)):
for j in range(v):
if sum([i + 1, j + 1]) > 0 and i != j:
if x[i] + x[j] == avg:
print(i + 1, j + 1)
x[i] = 0
x[j] = 0
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = input().split()
b = sorted([(int(l[i]),i+1) for i in range(n)])
# print(b)
for i in range(n // 2):
print(b[i][1], b[-1-i][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | raw_input()
cards = list(enumerate(map(int, raw_input().split())))
n = len(cards)
cards.sort(key=lambda x: x[1])
for i in range(n/2):
print cards[i][0]+1, cards[n-i-1][0]+1 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
b = sum(a) // (n // 2)
for i in range(n):
for j in range(i + 1, n):
if a[i] + a[j] == b:
a[i] = a[j] = 0
print(i + 1, j + 1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int,input().split()))
r = []
s = sum(a) // (n // 2)
for i in range(0,n):
r.append(False)
for i in range(0,n-1):
if r[i]==False:
for j in range(i+1,n):
if a[i]+a[j]==s and r[j]==False:
print(i+1, j+1)
r[j] = True
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int, input().split()))
l1 = []
for i in l:
l1.append(i)
l1.sort()
isk = sum(l1) // (n // 2)
b = []
while len(l1) > 0:
x = l1.pop()
y = isk - x
l1.remove(y)
b.append(x)
b.append(y)
d = []
for i in range(n):
for j in range(len(l)):
if b[i] == l[j]:
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
import java.io.*;
public class codeforces {
public static void main(String[] args) throws IOException
{
try{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int arr[]=new int[n];
int min=Integer.MAX_VALUE;
int max=0;
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
min=Math.min(min,ar... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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
n = int(input())
cards = list(map(int,input().strip().split()))
maxSum = max(cards) + min(cards)
counter = 0
for i in range(0, n):
if counter == int(n / 2):
break
for j in range(i+1, n):
if cards[i]+cards[j] == maxSum:
print(i+1,j+1)
counter += 1
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CF701A {
public static void main(String[] args) throws Exception{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 Solution(nums, length):
pairSum = sum(nums)*2/length
mp = {}
ans = [[0,0] for _ in range(length/2)]
index = 0
for i, num in enumerate(nums):
if num in mp and mp[num]:
curIndex = mp[num].pop()
ans[curIndex][1]= i+1
else:
ans[index][0] = i+1
leftover = pairSum - num
if leftover not in mp:
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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,y,ans=[],[],[]
y.append(0)
y.append(0)
x.append(y)
y=[]
for i in range(n):
y.append(l[i])
y.append(i+1)
x.append(y)
y=[]
x.sort()
for i in range(1,n//2+1):
y.append(x[i][1])
y.append(x[-i][1])
ans.append(y)
y=[]
for i in range(n//2):
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
map<int, vector<pair<int, int> > > pairs;
vector<int> vec, flag;
int cards, cardValue, sum = 0, average;
scanf("%d", &cards);
for (int x = 0; x < cards; x++) {
scanf("%d", &cardValue);
vec.push_back(cardValue);
flag.push_back(0);
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()) #number of items in list
arr = input()
arr = arr.split(" ") #list
#change all strings to ints
for i in range(n) :
arr[i] = int(arr[i])
temp = []
for i in range(n):
temp.append(i + 1)
for i in range(n // 2):
min_index = arr.index(min(arr))
max_index = arr.index(max(arr))
if arr[... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
public class cardGame {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t = n/2;
int[] a = new int[n];
int total = 0;
for(int i=0;i<n;i++)
{
a[i] = sc.nextInt();
total+=a[i];
}
total = total/t;
for(int... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
t = list(map(int, input().split()))
list = []
for i in range(n):
list.append((i+1,t[i]))
list.sort(key = lambda x:x[1])
for i in range(n//2):
print(list[i][0], list[-i-1][0]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def main():
n = int(input())
a = list(map(int, input().split(' ')))
sum = 0
for x in a:
sum += x
one = (2 * sum) // n
used = [False] * n
for i, x in enumerate(a):
if not used[i]:
used[i] = True
for j, y in enumerate(a):
if not used[j] 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... | # import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("outp.out",'w')
n=int(input())
a=list(map(int,input().split()))
s=int(2*sum(a)/n)
for i in range(n):
if a[i]!=-1:
x=s-a[i]
a[i]=-1
print(i+1,a.index(x)+1)
a[a.index(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... | #!/usr/bin/python3
def main():
n = int(input())
cards = [int(x) for x in input().split()]
pair = sum(cards)/(n/2)
can = list(range(n))
for i in range(int(n/2)):
atual = cards[can[0]]
for ind in can[1:]:
if atual + cards[ind] == pair:
print(can[0]+1, 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=input()
c=map(int,raw_input().split())
sumi=sum(c)/(n/2)
#print sumi
c=[[i,False] for i in c]
#print c
d={}
for i in range(n):
#print i
if c[i][1]==True:
#print i,'here'
continue
for j in range(n) :
#print j
if c[j][1]==True:
continue
if c[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... | import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<Integer> cards = new ArrayList<Integer>(n);
ArrayList<Integer> cardsBeforeSort = new ArrayList<... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()
cards=map(int, raw_input().strip().split(' '))
dcards=[]
for i in range(n):
dcards.append([cards[i], i+1])
scards=sorted(dcards)
#print dcards,scards
for i in range(n/2):
print scards[i][1], scards[-(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.Arrays;
import java.util.Scanner;
public class Test5 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()) {
int x=sc.nextInt();
int[] a=new int[x];
int[] b=new int[x];
for(int i=0;i<x;i++) {
a[i]=sc.nextInt();
b[i]=a[i];
}
Ar... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()
ns = map(int,raw_input().split())
nsi = range(1,n+1)
if(ns.count(ns[0]) == len(ns)):
for i in range(n/2):
print nsi[i*2],nsi[i*2+1]
else:
ans = zip(ns,nsi)
ans.sort()
final = [x for y, x in ans]
for i in range(n/2):
print final[i],final[-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.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Arrays.fill;
import static java.util.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... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author xwchen
*/
public class Main {
public static void main(String[] args) {
InputStream in... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
import java.io.*;
public class factor {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
PrintWriter op = new PrintWriter(System.out);
int n = in.nextInt();
int[] a = new int[n];
boolean[] vis = new boolean[n];
int sum = 0;
for(int i=0;i<n;i++){
a[i] =... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
l = []
for i in range(n):
l.append((a[i], i + 1))
l.sort()
for i in range(n // 2):
print(l[i][1], l[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... | t=input()
b=map(int,raw_input().split())
c=sum(b)
d=c*2/t
for i in range(0,t):
for j in range(0,t):
if i!=j and b[j]!=-1 and b[i]!=-1:
if b[i]+b[j]==d:
print i+1,j+1
b[i]=-1
b[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()
arr = map(int, raw_input().split())
arr = [(arr[i], i+1) for i in range(n)]
arr.sort()
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, t, a[105], sum = 0;
cin >> n;
t = n / 2;
for (int i = 1; i <= n; ++i) cin >> a[i], sum += a[i];
sum /= t;
for (int i = 1; i <= n; ++i) {
if (a[i] != 0) {
cout << i << " ";
for (int j = 1; j <= n; ++j) {
if (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... | input()
a = list(map(int, input().split()))
x = []
for i in range(0, len(a)):
for j in range(i+1, len(a)):
if a[i] + a[j] == max(a) + min(a) and i+1 not in x and j+1 not in x:
print(i+1, j+1, sep=" ")
x.append(i+1)
x.append((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.util.*;
public class Cards {
public static void main(String[] args){
int n;
int[] a=new int[110];
boolean[] flag=new boolean[110];
Arrays.fill(flag, false);
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
for(int i=1;i<=n;i++){
a[i]=sc.nextInt();
}
int[] b=Arrays.copyOf(a, a.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... | #include <bits/stdc++.h>
using namespace std;
int n;
int a[101];
int vis[101];
int main() {
scanf("%d", &n);
int sum = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
int ave = sum / (n / 2);
if (n == 2)
printf("1 2\n");
else {
for (int i = 1; i <= n; i++) {
for ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input().strip())
a=[int(i) for i in input().strip().split()]
used=[0 for i in range(n)]
s=sum(a)*2//n
for i in range(len(a)):
if used[i]==1:
continue
for j in range(i+1,len(a)):
if a[j]+a[i]==s and used[j]==0:
used[i]=1
used[j]=1
print(i+1,j+1)
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
A = list(map(int, input().split(' ')))
B = []
for i in range(n):
k = [A[i], i+1]
B.append(k)
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 n;
pair<int, int> a[10000];
int x;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &x);
a[i] = {x, i};
}
sort(a, a + n);
for (int i = 0; i < n / 2; i++)
cout << a[i].second + 1 << " " << a[n - i - 1].second + 1 << "\n";
re... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)//(n/2)
i = done = 0
while done<n/2:
while a[i]==0:
i += 1
j = i+1
while a[i]+a[j]!=s:
#print("aa",i,j,a[i]+a[j])
j += 1
print(i+1,j+1)
a[i] = a[j] = 0
done += 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;
vector<int> v;
long long n, a[101010], dp[1010][1010], ans = 0, av, b[1010], s = 1;
bool u[1010];
int main() {
cin >> n;
av = n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[i] = a[i];
}
for (int i = 1; i <= n; i++) {
u[i] = false;
}
sort(b + 1, 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 = input()
arr = map(int, raw_input().split())
x = (2*sum(arr)) / n
mapper = [True for i in xrange(n)]
for i in xrange(len(arr)):
if not mapper[i]: continue
for j in xrange(i+1, len(arr)):
if mapper[j] == False:
continue
if arr[j] != (x - arr[i]):
continue
print i+1, j+1
mapper[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())
M = list(map(int,input().split()))
for i in range(n):
M[i] = [M[i], i + 1]
M.sort()
for i in range(n//2):
print(M[i][1], M[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;
bool vis[102];
int main() {
int n;
cin >> n;
vector<pair<int, int> > v;
for (int i = 1; i <= n; i++) {
int a;
cin >> a;
v.push_back(make_pair((a), (i)));
}
sort((v).begin(), (v).end());
for (int i = 0; i < ((int)v.size()) / 2; i++) {
cout << v[... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.*;
import java.util.*;
import java.util.regex.*;;
import java.text.*;
import java.math.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] a=new int[n];
int[] b=new int[n];
int s=0;
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... | a=int(input())
l=list(map(int,input().split()))
q=sum(l)/(a/2)
for i in range(a):
for j in range(1,a):
if l[i]+l[j]==q and i!=j:
print(i+1,j+1)
l[i]=0
l[j]=0
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
pair<int, int> arr[101];
for (int i = 0; i < n; i++) {
arr[i].second = i + 1;
cin >> arr[i].first;
}
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... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOExc... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
z=list(map(int,input().split()))
y=int((sum(z)/n)*2)
count=0
for i in range(n) :
if int(count)==n//2 :
break
elif z[i]==-1 :
continue
else :
print(i+1,end=" ")
temp=z[i]
z[i]=-1
x=z.index(abs(y-temp))
print(x+1)
z[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... | x = int(input())
y = list(map(int,input().split()))
lst = []
j = 0
for i in y:
lst += [(i,j)]
j += 1
lst.sort()
for i in range(x//2):
print(lst[i][1]+1 , lst[x-i-1][1]+1)
i += 1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import sys
n = int(input())
alist = list(map(int, sys.stdin.readline().split()))
a = (sum(alist)*2)//n
adict = dict()
for i in range(n):
if alist[i] in adict:
adict[alist[i]].append(i)
else:
adict[alist[i]] = [i]
blist = [0]*n
for i in range(n):
if blist[i] == 0:
m = adict[a-alist[i]].pop()
adict[... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = [0] * n
split = int(sum(a) / (n/2))
for _ in range(int(n/2)):
found = False
for i in range(n):
for j in range(i+1, n):
if t[i] == 0 and t[j] == 0:
if a[i]+a[j] == split:
print(i+1, j+1)
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Stream;
/**
*
* @author Pradyumn Agrawal coderbond007
*/
public class Codeforces{
public... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
vs = list(map(int, input().split(" ")))
total = 0
for ele in vs:
total = total + ele
people = n//2
target = total//people
used = [False for i in range(n)]
for i in range(n):
if(used[i]):
continue
for j in range(i+1, n):
if(used[j]):
continue
if(vs[i]+vs[j] == target):
print("{} {}".forma... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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);
while(sc.hasNext()){
int a=sc.nextInt();
int []b=new int[100];
if(a%2==0) {
int c=a/2;
int sum=0;
for(int i=0;i<a;i++) {
b[i]=sc.nextInt(... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int size = input.nextInt();
int [] arr = new int [size];
int max=0; int min = 100;
for (int i=0; i < size; i++)
{
arr[i] = input.nextInt();
if (arr[i] > max)
max = arr... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
b.append([a[i],i])
b.sort()
for i in range(n//2):
print(str(b[i][1]+1)+" "+str(b[n-1-i][1]+1))
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
t = list(map(int, input().split()))
a = sorted([[t[i], i + 1] for i in range(n)])
for i in range(n // 2):
print(a[i][1], a[-i - 1][1])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
m = input().split()
z = n//2
sum = 0
s = []
for i in range(n):
sum += int(m[i])
for i in range(n):
for j in range(n):
if i not in s and j not in s and i != j:
if int(m[i]) + int(m[j]) == sum//z:
print(i+1,' ', j+1)
s.append(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.HashSet;
import java.util.Scanner;
import java.util.Set;
/**
* @author grozhd
*/
public class P1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] cards = new int[n];
for (int i = 0; i < n; i++) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
s=list(map(int,input().split()))
for i in range(n):
s[i]=(s[i],i+1)
s.sort()
for i in range(n//2):
print (s[i][1],s[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())
cards = list(map(int, input().split()))
each_s = min(cards) + max(cards)
idx = []
for i in range(n):
for j in range(n):
if i != j and cards[i] + cards[j] == each_s and j not in idx and i not in idx:
print(i + 1, j + 1) if cards[i] <= cards[j] else print(j + 1, i + 1)
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Arrays;
import java.util.Scanner;
public class _701_A_Cards {
public static void main(String[] args) throws Exception {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[][] a = new int[n][2];
for (int i = 0; i < n; i++) {
a[i][0] = in.nextInt();
a[i][1] = i + 1;
}
Arra... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=input()
a=a.split()
for i in range(n):
a[i]=int(a[i])
minn=101
maxx=0
ans=[]
for i in range(int(n/2)):
ans=ans+[-1, -1]
minn=101
maxx=0
for j in range(n):
if(a[j]>maxx):
maxx=a[j]
ans[2*i]=j
a[ans[2*i]]=int(-1)
for j in range(n):
if(a[... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | cards = int(input())
# card_values = []
# for x in range (0, cards):
# card_values.append(int(input()))
card_values = list(map(int, input().split()))
sum_values = sum(card_values)
target = sum_values / (cards/2)
for i in range(0, cards):
if card_values[i] != -1:
x = card_values[i]
for j in r... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
x=list(map(int,input().split()))
for i in range(a):
x[i]=[x[i],i+1]
x.sort()
x=[[0,0]]+x
for i in range(a//2+1):
if i!=0:
print(x[i][1],x[-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 long long int MOD = 1e9 + 7;
bool IsPowerOfTwo(long long int x) { return (x != 0) && ((x & (x - 1)) == 0); }
long long int poer(long long int a, long long int b) {
long long int rs = 1;
while (b > 0) {
if (b & 1) rs *= a;
a *= a;
b /= 2;
}
return r... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = 5e5 + 100;
int n, c;
int t[maxn];
struct p {
int val;
int pos;
} r[maxn];
bool cmp(p a, p b) { return a.val < b.val; }
int main() {
cin >> n;
map<int, int> pos;
for (int i = 1; i <= n; i++) cin >> r[i].val, r[i].pos = i;
sort(r + 1, r + n + 1, 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... | import java.util.Arrays;
import java.util.Scanner;
public class ACM {
Scanner io = new Scanner(System.in);
String inputString;
public static void main(String[] args) {
ACM temp = new ACM();
}
public ACM() {
int n = io.nextInt();
int arr[] = new int[n];
int sum = 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 x;
cin >> x;
vector<int> v(x);
vector<int> in(x);
for (int i = 0; i < x; i++) {
cin >> v[i];
in[i] = i + 1;
}
for (int i = 0; i < x; i++) {
for (int j = 0; j < x - i - 1; j++) {
if (v[j] > v[j + 1]) {
int t = v[j];
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Aaa {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
Integer[] arr = new Integer[n];
Integer[] check = new Integer[n];
for (int i = 0; i < n; i++){
arr[i] = sc.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 = input()
a = map(int, raw_input().split())
a = [(a[i], i + 1) for i in xrange(n)]
a.sort()
for i in xrange(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 = input() #input n
a = input()
a = a.split(' ')
l = []
for i in a:
l.append(int(i))
lsorted = sorted(l)
index = []
for i in range(len(l)):
index.append(l.index(lsorted[i]))
l[l.index(lsorted[i])] = -1
same = True
for i in range(1,len(l)):
if lsorted[i] != lsorted[i-1]:
same =False
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int n, a[101];
float av, sum;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
av = (sum / n) * 2;
for (int i = 1; i <= n; i++) {
if (a[i] != 0) {
for (int j = 1; j <= n; j++) {
if (a[i] + a[j] == av && i ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
A = list(map(int, input().split()))
for i in range(n):
A[i] = [A[i], i + 1]
A.sort()
for i in range(n // 2):
print(A[i][1], A[-i-1][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import sys
n = int(raw_input())
ara = map(int, raw_input().split())
freq = range(1,n+1)
x = sorted(zip(ara,freq))
for i in range(n/2):
print(str(x[i][1])+" "+str(x[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 = input()
cards = map(int, raw_input().split())
pos = {}
for i in xrange(n):
card = cards[i]
pos[card] = pos.get(card, []) + [i+1]
cards.sort()
for i in xrange(n/2):
first = cards.pop(0)
last = cards.pop()
print pos[first].pop(0), pos[last].pop(0)
if first in pos and len(pos[first]) == 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()))
avg = sum(l)//(n//2)
ok = [True for i in range(n+1)]
for i in range(n):
if not ok[i]: continue
ok[i] = False
for j in range(n):
if ok[j] and l[i]+l[j] == avg:
ok[j] = False
print(i+1, j+1)
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
int main() {
int k, avg, n, sum = 0, i, j;
int ar[100];
scanf("%d", &n);
k = n / 2;
for (i = 0; i < n; i++) {
scanf("%d", &ar[i]);
sum += ar[i];
}
avg = sum / k;
for (i = 0; i < n; i++) {
if (ar[i] != 0) {
for (j = 0; j < n; j++) {
if (((ar[i] + ar[j]) ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
bool mycompare(pair<long long int, long long int> v1,
pair<long long int, long long int> v2) {
return v1.first < v2.first;
}
int main() {
long long int n;
cin >> n;
pair<long long int, long long int> a[n];
long long int position = 1, value;
for (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... | n=int(input())
cards=list(map(int,input().split()))
x=int(sum(cards)/(n/2))
visited=[False]*n
for i in range(len(cards)-1):
for j in range(i+1,len(cards)):
if x==cards[i]+cards[j] and visited[j]==False and visited[i]==False:
ipair=j
visited[i] = True
visited[ipair] = 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())
c = list(map(int,input().split()))
tot = sum(c) // (n//2)
b = [0]*len(c)
for i in range(n):
if b[i] == 0:
p = i + 1 + c[i+1:].index(tot - c[i])
b[p] = 1
b[i] = 1
if c[i] <= c[p]:
print(i+1, p+1)
else:
print(p+1, i+1)
c[i] = -1
c[p] = -1 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;
public class Cards {
static StringTokenizer st;
static BufferedReader bf = new BufferedReader(new... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()))
index = list(range(1, n + 1))
for i in range(n // 2):
min_index = cards.index(min(cards))
cards.pop(min_index)
print(index.pop(min_index), end=' ')
max_index = cards.index(max(cards))
cards.pop(max_index)
print(index.pop(max_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=[*map(int,input().split())]
index=[]
for i in range(n):
index.append(i+1)
for i in range(n-1,0,-1):
for j in range(i):
if l[j]>l[j+1]:
l[j],l[j+1]=l[j+1],l[j]
index[j],index[j+1]=index[j+1],index[j]
for i in range(n//2):
print(index[i],index[n-i-1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int arr[102][102] = {0}, a[102], n, sum = 0, v[102] = {0};
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
arr[a[i]][v[a[i]]++] = i + 1;
sum += a[i];
}
sort(a, a + n);
n /= 2;
sum /= n;
for (int j = 0; j < n; j++) {
cout << ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
double eps = 0.000001;
struct node {
int x, id;
};
node tm[105];
vector<int> sb[105];
int ans[105][2];
bool cmp(node a, node b) { return a.x < b.x; }
int main() {
int n;
cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++) {
scanf(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.