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... | import java.util.*;
import java.io.*;
public class Solution {
static class D{
int i,val;
D(int i,int v){
this.i = i;
this.val = v;
}
}
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readL... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.management.MemoryType;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.function.Function;
public clas... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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() {
cin.tie(NULL);
ios_base ::sync_with_stdio(false);
int n;
cin >> n;
vector<pair<int, int> > ve;
for (int i = 0; i < n; ++i) {
int t;
cin >> t;
ve.push_back(make_pair(t, i + 1));
}
sort(ve.begin(), ve.end());
for (int i = 0; i < n / ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
const int S = 100003;
const int MOD = 1000000007;
int _I() {
int x;
scanf("%d", &x);
return x;
}
long long _LL() {
long long x;
scanf("%lld", &x);
return x;
}
int dirX[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dirY[] = {0, 1, 0, -1, 1, -1, -1, 1};
int rX[] = {1, 1, 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;
template <typename T>
T scani(T &n) {
n = 0;
bool negative = false;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') negative = true;
c = getchar();
}
while (c >= '0' && c <= '9') {
n = n * 10 + c - 48;
c = getchar();
}
if (nega... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()]
pair = []
ne = max(a)+min(a)
for i in range(n):
for ii in range(i+1, n):
if a[i] != 0 and a[ii] != 0 and a[i]+a[ii] == ne:
pair.append([i+1, ii+1])
a[i] = 0
a[ii] = 0
for i in pair:
print(*i)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
lst = list(map(int, input().split()))
srt = list(enumerate(lst))
srt = sorted(srt, key=lambda card: card[1])
i = 1
for j in range(n // 2):
print(srt[i - 1][0] + 1, srt[-i][0] + 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())
cards = [int(i) for i in input().split()]
flag = [False for i in range(n)]
val = 2*sum(cards)//n
for i in range(n):
if not flag[i]:
for j in range(i+1, n):
if not flag[j] and cards[i] + cards[j] == val:
print(i+1, j+1)
flag[i], flag[j] = True, Tr... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | # You lost the game.
n = int(input())
L = list(map(int, input().split()))
T = [[L[i], i+1] for i in range(n)]
def ct(a):
return a[0]
T.sort(key=ct)
for i in range(n//2):
print(str(T[i][1])+" "+str(T[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/python2
#... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
import java.io.*;
import java.math.BigDecimal;
public class TestClass{
static PrintWriter out = new PrintWriter(System.out);
static LinkedList g;
public static void main(String args[]) throws Exception
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Inte... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
s = (2*sum(arr))/n
i = 0
c = 0
while c!=n/2:
i = 0
while i<n and arr[i]==-1:
i+=1
j = i+1
#print i,j
while j<n and arr[i]+arr[j]!=s:
j+=1
#j = arr.index(s-arr[i])
arr[i] = -1
arr[j] = -1
print i+1,j+1
c+=1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def main():
n = int(input())
a = sorted(zip(map(int, input().split(' ')), range(1, n + 1)))
for i in range(n // 2):
print(a[i][1], a[- i - 1][1])
if __name__ == "__main__":
main()
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | # import sys
# sys.stdin=open("input.in","r")
# sys.stdout=open("output.out","w")
n=int(input())
l=[[int(i),0] for i in input().split()]
for i in range(n):
l[i][1]=i+1
l.sort()
for i in range(n//2):
print(l[i][1],l[n-i-1][1])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(raw_input())
N=map(int,raw_input().split())
a=[[0 for i in range(2)] for i in range(n)]
for i in range(n):
a[i][0]=N[i]
a[i][1]=i+1
a.sort()
i=0
j=n-1
while i<j:
print a[i][1],a[j][1]
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 a[105];
pair<int, int> p[105];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
p[i] = make_pair(a[i], i);
}
sort(p, p + n);
for (int i = 0, j = n - 1; i < n / 2; i++, j--) {
cout << p[i].second + 1 << " " << p[j].second +... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
public class a701 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt(), s = 0;
int[] a = new int[n];
for (int i = 0; i < n; ++i) s += (a[i] = in.nextInt());
s /= (n / 2);
boolean[] mark = new boolean[n];
for (int i = 0; i < n; ++i) if (!... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=sorted(zip(map(int,input().split()),range(1,n+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... | n = int(input())
m = list(map(int, input().split()))
aa = list.copy(m)
aa.sort()
dd = aa[0] + aa[-1]
igr = [n + 1]
for i in range(n):
qq = m[i]
for j in range(i + 1, n):
ww = m[j]
for jj in igr:
ee = m.index(m[i])
pp = m.index(m[j])
if m.index(m[i]) != jj and ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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=[int(i) for i in raw_input().strip().split()]
for i in range(len(a)):
a[i]=[a[i],i+1]
a.sort()
for i in range(n/2):
print a[i][1], a[n-i-1][1]# your code goes here |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.List;
import java.util.Scanner;
public class CardsGame {
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int numOfCards = scan.nextInt();
int[] input = new int[numOfCards];
int sum = 0;
List<Integer> out = new ArrayList<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... | //package com.company;
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
//public class Cards {
public class Main {
public static class Pair implements Comparable<Pair> {
int x;
int y;
public Pair(int x, int y) {
this.x = x;
this.y = y;... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | /**
* Created by abhishek on 7/24/2016.
*/
import java.util.*;
import java.io.*;
public class Main {
public static void main(String [] args)throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer 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())
List=list(map(int,input().split(' ')))
numDict={}
for index,value in enumerate(List):
numDict[index]=value
numList=sorted(numDict.items(),key=lambda x:x[1])
for i in range(int(n/2)):
a=numList[i][0]
b=numList[-(i+1)][0]
print(str(a+1)+' '+str(b+1))
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
def distribute(numbers):
sum = 0
i=0
free = [0]*len(numbers)
for x in numbers:
sum = sum + int(x)
singleSum = sum*2/len(numbers)
for x in range(0,len(numbers)-1):
if free[x]==1:
continue
for y in range(x+1,len(numbers)):
if free[y]==0 and (int(nu... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
l = map(int,raw_input().split())
a = l[0::]
a.sort()
for i in xrange(n/2) :
x = l.index(a[i])
l[x] = -1
y = l.index(a[n-1-i])
l[y] = -1
print '%d %d' %(x+1,y+1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def cards(lst):
a = list()
for i in range(len(lst)):
a.append(tuple((lst[i], i + 1)))
b = sorted(a)
c = list()
for i in range(len(b) // 2):
c.append(tuple((b[i][1], b[len(b) - i - 1][1])))
return c
n = int(input())
d = [int(j) for j in input().split()]
for elem in cards(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... | i=int(input())
l=list(map(int,input().split()))
a=sum(l)//(i//2)
for x in range(len(l)):
if l[x]!='*':
b=l[x]
for y in range(x+1,len(l)):
c=a-b
if l[y]==c:
print(x+1,y+1)
l[y]="*"
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... | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
n=int(input())
a=list(map(int,input().split()))
tot = 0
for elem in a:
tot += elem
score = int(tot/(n/2))
nbjoueur = int(n/2)
for joueur in range(nbjoueur):
for i in range(n):
for j in range(n):
if (not i ==... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=input()
a=map(int,raw_input().split())
b=[[] for _ in range(101)]
for i in range(n):
b[a[i]]+=[i+1]
s=max(a)+min(a)
for x in sorted(a)[:n/2]:
if(x==s-x):
print b[x][0],b[x][1]
b[x]=b[x][2:]
else:
print b[x][0],b[s-x][0]
b[x]=b[x][1:]
b[s-x]=b[s-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 = input()
class Card:
def __init__(self, index, value):
self.index = index
self.value = value
def __repr__(self):
return "(I: {0}, V: {1})".format(self.index, self.value)
cards = []
for index, v in enumerate(map(int, raw_input().split())):
cards.append(Card(index + 1, v))
def compare(a, b):
return a.va... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(int(input())/2)
a = list(map(int, input().split()))
x = int(sum(a)/n)
b = []
for i in range(len(a)):
if i in b:
continue
else:
for j in range(i+1,len(a)):
if a[i] + a[j] == x and j not in b:
print(i+1, j+1, sep=' ')
b.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.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
public class Main {
public static void main(String args[]) throws Exception {
class Point implements Comparable<Point> {
int index;
int value;
public Point(int index,int va... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.*;
import java.math.*;
import java.io.*;
import java.util.Collections;
public class Solution {
static class Solver {
Solver() {
}
public void solve(FastScanner sc, PrintWriter out) throws IOException {
int n = sc.nextInt();
int[] arr = new int[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 = map(int, raw_input().split())
vals = {}
for n, v in enumerate(a):
vals.setdefault(v, []).append(n)
tot = sum(a) / (len(a) / 2)
selected = set()
for i in range(len(a)):
if i in selected:
continue
v = a[i]
w = tot - v
indexes = vals[w]
w_idx = indexes.pop()
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... | n=input()
a=sorted(zip(map(int,raw_input().split()),range(1,n+1)))
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... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class A701_Cards {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n, avg = 0, arr[105];
cin >> n;
bool used[105] = {0};
map<long long, stack<long long>> m;
for (long long i = 0; i < n; i++) {
cin >> arr[i];
m[arr[i]].push(i + 1);
avg += arr[i];
}
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | take=lambda:raw_input().strip()
calculate=lambda:list(map(int,raw_input().strip().split(' ')))
N=int(take())
ans=zip(calculate(),xrange(1,N+1))
ans.sort()
for i in xrange(N/2):
print ans[i][1],ans[N-i-1][1] |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Arrays;
import java.util.Scanner;
public class Cards {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] cards= new int[n];
int [] ordered = new int[n];
for (int i = 0; i < n; i++) {
cards[i]=s.nextInt();
ordered[i] = cards[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())
cards = [int(num) for num in input().split(' ')]
sr_value = int(sum(cards) * 2 / n)
for i in range(n - 1):
for j in range(i + 1, n):
if cards[i] != 0 and cards[j] != 0 and (cards[i] + cards[j] == sr_value):
print(i + 1, j + 1)
cards[i] = 0
cards[j] = 0
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.*;
public final class Cards{
static class Index{
int val = -1;
Index next = null;
}
public static void main(String args[]) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N, val[] = new int[100], a[];
Index IN[] = new Index[100];
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())
data = input().split(sep=' ')
int_data = []
for i in range(n):
int_data.append((int(data[i]), i + 1))
int_data.sort(key=lambda x: x[0])
for i in range(n // 2):
print(int_data[i][1], int_data[n - 1 - i][1], sep=' ')
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
pair<int, int> p[105];
int main(void) {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
scanf("%d", &p[i].first);
p[i].second = i + 1;
}
sort(p, p + n);
for (int i = 0, j = n - 1; i < n / 2; i++, j--) {
printf("%d %d\n", p[i].second, p[j].second);
}... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | //package codeforces;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
/**
* Created by nitin.s on 22/07/16.
*/
public class Cards {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.*;
import java.util.HashMap;
import java.util.Stack;
public class Main {
public static void main(String args[])throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(obj.readLine());
String temp[]=obj.readLine().split(" ");
int arr[]=new 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[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())
x=list(map(int,input().split()))
y=[[x[i],i+1] for i in range(len(x))]
y=sorted(y,key=lambda x:x[0])
while y!=[]:
print(y.pop(0)[1],y.pop(-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, a[100], s = 0, i, j;
int vis[100];
for (i = 0; i < 100; i++) vis[i] = 0;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a[i];
s += a[i];
}
s /= (n / 2);
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
if (a[j] + a[i]... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
/**
* Created by user on 04.02.2017.
*/
public class A701a {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = scanner.nextI... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import sys
if __name__ == '__main__':
a = sys.stdin.readline()
b = list(map(int, sys.stdin.readline().split(" ")))
c = sum(b) / (len(b) / 2)
d = b.copy()
for i in range(0, len(d)):
if b[i] != -1:
for j in range(i + 1, len(d)):
if b[j] != -1 and b[i] + b[j] == c:
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
float av, sum;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
av = (float)(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... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 = list(enumerate(map(int, raw_input().split())))
A.sort(key = lambda x : x[1])
for i in range(N/2):
print str(A[i][0]+1)+" "+str(A[-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())
arr = list(map(int,input().split()))
arr1 = []
for k,v in enumerate(arr):
arr1.append([v,k])
arr1.sort()
for i in range(n//2):
print(arr1[i][1]+1,arr1[-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... | def main():
n = int(input())
a = sorted(enumerate(map(int, input().split(' '))), key=lambda x: x[1])
for i in range(n // 2):
print(a[i][0] + 1, a[- i - 1][0] + 1)
if __name__ == "__main__":
main()
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def cards(a,N):
sum=0
b=a
c=a[:]
for item in a:
sum=sum+item
avg=sum/(N/2)
'''for item in a[:]:
#a.remove(item)
for item2 in b[1:]:
print(c.index(item))
print(c.index(item2))
if a==[]:
break
elif item+item2==... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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(num_order, n):
num_order.sort()
for idx in xrange(n/2):
print num_order[idx][1], num_order[n-1-idx][1]
# solve([(1,1), (5,2), (7,3), (4,4), (4,5), (3, 6)], 6)
# solve([(10,1),(10,2),(10,3),(10,4)],4)
n = input()
m = map(int, raw_input().split())
# print m
r = []
for idx in xrange(n):
r.append((m[idx... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
num=list(map(int,input().split()))
for i,e in enumerate(num):
num[i]=(i+1,e)
num.sort(key=lambda x:x[1])
i=0
j=len(num)-1
while i<j:
print(num[i][0],num[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... | def distribute(deck):
s = sum(deck)//(len(deck)//2)
idx_by_val = [[] for x in xrange(101)]
for i, card in enumerate(deck):
match_card = s - card
if idx_by_val[match_card]:
print '%s %s' % (i+1, idx_by_val[match_card].pop()+1)
else:
idx_by_val[card].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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int nums[101];
bool bn[101];
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> nums[i];
sum += nums[i];
bn[i] = true;
}
sum = sum / (n / 2);
for (int i = 0; i < n; i++) {
if (bn[i]) {
for (int j = 0; j < ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | N = int(input())
A = list(map(int, input().split()))
sum = 0
for a in A:
sum += a
for i in range(N):
for j in range(N):
if i != j and A[i] + A[j] == sum / N * 2:
print(i+1, j+1)
A[i] = 0
A[j] = 0
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
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.IOException;
import java.util.Com... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | # coding: utf-8
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
n = int(input())
a = li... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 __file__.startswith('/tmp/'):
import sys; sys.stdin = open('input.txt')
n = int(raw_input())
a = sorted(enumerate(map(int, raw_input().split()), 1), key=lambda (x, y): y)
for i in xrange(len(a) / 2):
print a[i][0], a[n-1-i][0] |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = [int(a) for a in input().split()]
b = a[:]
s = []
while len(b) != 0:
s.append(max(b))
b.remove(max(b))
s.append(min(b))
b.remove(min(b))
for i in range(0,n-1,2):
print(a.index(s[i+1]) + 1, end = " ")
a[a.index(s[i+1])] = 0
print(a.index(s[i]) + 1)
a[a.index(s[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, cards, total = input(), input().split(' '), 0
for i in range(0, len(cards)):
total += int(cards[i])
use = {}
average = total / int(n) * 2
for i in range(0, int(n)):
target = int(average - int(cards[i]))
for j in range(0, int(n)):
if i != j and bool(use.get(i)) != True and bool(use.get(j)) != Tru... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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(lambda x, i: (i, int(x)), input().split(), range(1, n+1)))
cards.sort(key=lambda x: x[1])
for i in range(n//2):
print(cards[i][0], cards[n-1-i][0])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def division():
n = int(input())
a = [(int(num), i) for i, num in enumerate(input().split(), 1)]
a.sort()
for i in range(n // 2):
print(a[i][1], a[n - 1 - i][1])
division() |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 Bitplus():
n = int(input())
x = 0
for i in range(n):
a = input()
if "+" in a:
x += 1
else:
x -= 1
print(x)
def GiftSetidk():
n = int(input())
for i in range(n):
all = input().split(" ")
x = int(all[0])
y = int(all[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):
a1=[a[i],i]
b.append(a1)
b.sort()
for i in range(n//2):
print(b[i][1]+1,end=" ")
print(b[n-i-1][1]+1) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class A701 {
void go(Scanner s) {
int N = s.nextInt(), stk[][] = new int[101][N + 1], sum = 0;
for(int i = 1, v; i <= N; i++) {
sum += (v = s.nextInt());
stk[v][++stk[v][0]] = i;
}
int each = sum / (N / 2);
for(int i = 1; i <= 100; i++) {
while(stk[i][0] > 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()))
m = sum(a)/(n/2)
cnt = {}
for each in a:
cnt[each] = a.count(each)
used = [0 for each in a]
def getFirstId(value):
for i in range(len(a)):
if ((not used[i])and(a[i]==value)):
used[i] = True
return i+1
for each in cnt.keys():
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
array = list(map(int, input().split()))
a = [0]*n
i = 0
while i < n:
a[i] = i
i += 1
i = 0
while i < n-1:
for j in range(n-i-1):
if array[j] > array[j+1]:
array[j],array[j+1] = array[j+1],array[j]
a[j],a[j+1] = a[j+1],a[j]
i += 1
i = 0
while i < int (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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
while (cin >> n) {
int a, arr[10000], d = 0, s = 0, b;
for (i = 1; i <= n; i++) {
scanf("%d", &a);
arr[d++] = a;
s += a;
}
b = s / (n / 2);
for (int i = 0; i < s; i++) {
for (int j = i + 1; j < s; j++) {... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
n = int(input())
l = list(map(int, input().split()))
lp = []
su = sum(l)
to = su // (n // 2)
for i in range(n):
for j in range(i + 1, n):
if l[i] + l[j] == to:
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())
cards = [int(x) for x in input().split()]
new_l = []
for i in range(n):
new_l.append((cards[i], i+1))
lst = sorted(new_l, key=lambda x: x[0])
for i in range(n // 2):
print(lst[i][1], lst[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>
const int MAXN = (int)1e5 + 5;
const int MODN = (int)1e9 + 7;
int inf = 0x3f3f3f3f;
using namespace std;
char str[MAXN];
int num[MAXN];
int a[MAXN];
int vis[MAXN];
int main() {
int n, m;
while (scanf("%d", &n) != EOF) {
memset(vis, 0, sizeof(vis));
int sum = 0;
for (int i = 0; i... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
struct haha {
int wei, zhi;
} a[105];
int my_comp(const haha &q, const haha &w) {
if (q.zhi < w.zhi) return 1;
return 0;
}
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i].zhi);
a[i].wei = i;
}
sort(a + 1, 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... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long MOD = 12345678910;
const long double eps = 1e-13;
const int imax = INT_MAX;
int main() {
cin.tie(0);
ios_base ::sync_with_stdio(0);
int n;
cin >> n;
vector<pair<int, int> > a(n);
for (int i = 0; i < n; i++) {
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... | import sys,math,string
input=sys.stdin.readline
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
n=int(input())
l=L()
f=[]
for i in range(n):
f.append([l[i],i])
f.sort(key=lambda x: x[0])
for i in range(n//2):
print(f[i][1]+1,f[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... | import sys
input=sys.stdin.readline()
n= int(input)
input=sys.stdin.readline()
arr = list(map(int, input.split()))
ar=[]
for i in range(n):
ar.append([arr[i], i+1])
ar.sort()
for i in range(n//2):
print(ar[i][1], ar[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())
t=list(map(int,input().rstrip().split()))
m=n/2
sum=0
for i in range(n):
sum=sum+t[i]
avg=sum/m
for j in range(0,n):
for k in range(j+1,n):
if (t[j]+t[k]==avg ):
print(j+1,end=" ")
print(k+1)
t[j]=0
t[k]=0
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.ArrayList;
import java.util.Scanner;
public class CardPairs {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt(), i, j, s = 0;
ArrayList<Integer> a = new ArrayList<Integer>();
for (i = 0; i < n; i++) {
int x = in.nextInt();
a.add(x);
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CF_364_B {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine()... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | a=int(raw_input())
l=map(int,raw_input().split())
v=sum(l)/(a/2)
vis=[False]*a
for i in xrange(a):
if not vis[i]:
for j in xrange(i+1,a):
if not vis[j]:
if l[i]+l[j]==v:
print str(i+1)+' '+str(j+1)
vis[i]=True
vis[j]=True
break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | 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:
ipair=j
break
if visited[i]==False and visited[ipair]==False:
visited... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
ar=list(map(int,input().split()))
t=max(ar)+min(ar)
for i in range(len(ar)-1):
for j in range(i+1,len(ar)):
if ar[i]+ar[j]==t:
print(i+1,j+1)
ar[i]=0
ar[j]=0
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class _364_1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int sum=0;
int a[]=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())
ar = input().split()
for i in range(0, n):
ar[i] = int(ar[i])
s = sum(ar)*2//n;
t = 0;
for i in range(0, n//2):
while(ar[t]==0):
t+=1
temp = ar[t]
ar[t]=0
print(t+1, ar.index(s-temp)+1);
ar[ar.index(s-temp)]=0
t+=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()/2
cards = map(int, raw_input().split(" "))
each = sum(cards)/n
ans = []
while(sum(cards)>0):
maxVal = max(cards)
ans.append(cards.index(maxVal)+1)
cards[cards.index(maxVal)] = 0
ans.append(cards.index(each - maxVal)+1)
cards[cards.index(each - maxVal)] = 0
for i in range(0,len(ans),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 = []
for i in xrange(n):
B.append((A[i], i + 1))
B.sort()
for i in xrange(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;
bool ud[105];
int a[105];
int main() {
int n, sum = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
sum = (sum * 2) / n;
for (int i = 1; i < n; i++) {
if (ud[i]) continue;
for (int j = i + 1; j <= n; j++) {
if (ud[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 math
n = int(input())
a = list(map(int, raw_input().split()))
b = [i for i in range(n)]
def cmp(x, y):
if a[x] < a[y]: return 1
elif a[x] > a[y]: return -1
else: return 0
b.sort(cmp)
for i in range(0, n // 2):
print("%d %d"%(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... | import sys
from math import sqrt, floor, factorial
from collections import deque
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
def solve():
n = int(inp()); ans = ""
arr = sorted(zip(read(), range(n)))
for i in range(n//2):
ans += str(arr[i][1]+1) + " " + str(arr[n-i-1][1]+1)+"\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(enumerate(map(int, input().split()), 1))
a.sort(key=lambda x: x[1])
for i in range(n//2):
print(a[i][0], a[n-1-i][0])
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
lst = [int(i) for i in input().split()]
d = {}
for i in range(len(lst)):
if lst[i] not in d:
d[lst[i]] = [i + 1]
else:
d[lst[i]].append(i + 1)
lst.sort()
for i in range(len(lst) // 2):
print(d[lst[i]][-1], end=" ")
d[lst[i]].pop()
print(d[lst[-1-i]][-1])
d[lst[-... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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> m[101];
int a[101];
int main() {
int n, sum = 0, target;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum += a[i];
m[a[i]].push_back(i);
}
target = (2 * sum) / n;
int pos, pos2;
for (int i = 1; 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())
cards = list(map(int, input().split()))
half = sum(cards) * 2 // n
for i in range(n- 1):
for j in range(i + 1, n):
if cards[i] + cards[j] == half:
print(i + 1, j + 1)
cards[i] = cards[j] = 0
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int ceil1(long long int n, long long int k) {
if (n % k) return n / k + 1;
return n / k;
}
long long int pow1(long long int n, long long int k, long long int modu) {
long long int ans = 1;
while (k != 0) {
if (k % 2) ans = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.