prompt string | response string |
|---|---|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int, input().rstrip().split()))
l = sorted([[j,i+1] for i,j in enumerate(l)])
for i in range(n//2):
print(l[i][1], l[-(i+1)][1]) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
s = sum(a) // (n >> 1)
for k in range(n >> 1):
for i in range(n - 1):
for j in range(i + 1, n):
if (a[i] + a[j]) == s:
print(i + 1, j + 1)
a[i] = -1000000
a[j] = -1000000
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
seq = [int(j) for j in input().split(" ")]
k = sum(seq) / (n//2)
results = []
first_index = 0
for i in range(n//2):
res = str(first_index+1)
first_number = seq[first_index]
j = first_index+1
while seq[j] != k-first_number:
j += 1
res += " " + str(j+1)
(seq[first_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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class ABC {
public static void main(String[] args) throws IOException{
Scanner sc = 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... | #include <bits/stdc++.h>
using namespace std;
int cnt[300];
int main() {
int n, c, i, dif, ans = 1, j, k, d = -1;
vector<int> vec;
vector<int> v;
cin >> n;
int ara[n], cp[n];
for (i = 0; i < n; i++) {
cin >> ara[i];
cp[i] = ara[i];
}
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Cards_1 {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
String s[]=br.readLine().spli... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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, a;
cin >> n;
vector<pair<int, int> > v;
for (i = 1; i <= n; i++) {
cin >> a;
v.push_back({a, i});
}
sort(v.begin(), v.end());
for (i = 0; i < n / 2; i++) {
cout << v[i].second << " " << v[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... | def readInt(): return int(raw_input())
def readList(): return map(int, raw_input().split(' '))
n = readInt()
b = readList()
a = sorted(b[:])
for i in xrange(n/2):
for j in xrange(n):
if b[j] == a[i]:
print j+1,
b[j] = -1
break
for j in xrange(n):
if b[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... | /**
* Created by Priyam_Lapy on 22-Jul-16.
*/
import java.util.*;
public class Cards {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int arr[]=new int[n];
int pos[]=new int[n];
for(int i=0;i<n;i++)
{arr[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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
pair<int, int> a[101];
cin >> n;
for (i = 1; i <= n; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a + 1, a + n + 1);
for (i = 1; i <= n / 2; i++) {
cout << a[i].second << " " << a[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... | n=int(input())
c=list(map(int, input().split()))
s=sum(c)/n*2
left=set(range(n))
while True:
i=min(left)
for j in left:
if i==j: pass
elif c[i]+c[j]==s:
x=i; y=j
print(i+1, j+1)
break
left-={i, j}
if len(left)==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.Scanner;
public class CodeForces {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
float n = scan.nextFloat();
float sum=0;
float []k = new float[Math.round(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())
l=[int(i) for i in input().split()]
s=sum(l)//(n//2)
for i in range(n):
for j in range(i+1,n):
if l[i]+l[j]==s:
l[i]=l[j]=0
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(raw_input().strip())
a = map(int, raw_input().strip().split(' '))
b = sorted([(a[i], i) for i in range(n)])
for i in range(n/2):
print b[i][1]+1, b[-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... | #include <bits/stdc++.h>
int main() {
int n, h(0), t;
std::array<int, 2> a[100];
std::scanf("%d", &n);
for (int i(0); i < n; ++i) {
std::scanf("%d", &a[i][0]);
a[i][1] = i + 1;
}
t = n - 1;
std::sort(a, a + n);
while (h < t) {
std::printf("%d %d\n", a[h][1], a[t][1]);
++h, --t;
}
ret... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import math
n = int(input())
a = list(map(int, input().split()))
b = [[a[i], i + 1] for i in range(n)]
b.sort()
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 java.util.Arrays;
import java.util.*;
public class NewMain12 {
public static void main(String[] args) {
// TODO code application logic here
Scanner s = new Scanner(System.in);
int x = s.nextInt();
ArrayList<card> hm = new ArrayList<>();
for (int i = 0; i < x; 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.*;
import java.util.*;
public class class701A{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int[] mas = new int[n];
for(int i = 0; i < n; i++){
mas... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 INF = numeric_limits<int>::max();
const long long LINF = numeric_limits<long long>::max();
const double DINF = numeric_limits<double>::max();
const double EPS = 1e-9;
const int ITER = 10000;
const int MOD = 1e9 + 7;
const int MAXN = 205;
pair<int, int> a[MAX... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
cv = [int(x) for x in input().split()]
minmax = min(cv) + max(cv)
for x in range(cards):
if(cv[x] != 0):
a = cv.index(cv[x])
b = cv.index(minmax-cv[x])
if(a != b):
print(a+1,b+1)
cv[a] = 0
cv[b] = 0
else:
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/python
from collections import deque
def ir():
return int(raw_input())
def ia():
line = raw_input()
line = line.split()
return map(int, line)
n = ir()
a = ia()
a = [(e, i+1) for i, e in enumerate(a)]
a.sort()
for i in range(n//2):
j = n - i - 1
ai = a[i]
aj = a[j]
p... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
l=list(map(int,input().split(" ")))
s=sum(l)//(n/2)
for i in range(n):
for j in range(i+1,n):
if l[j]!=0:
if l[i]+l[j]==s:
print(i+1,j+1)
l[i]=0
l[j]=0 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int p[105][105], top[105] = {0};
void stack_push(int n, int j) {
p[n][top[n]] = j;
top[n]++;
}
int main() {
int n, arr[105];
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> arr[i];
stack_push(arr[i], i);
}
sort(arr + 1, arr + n + 1);
for (int 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.*;
public class Main {
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] valores=new int[n];
int menor=Integer.MAX_VALUE;
int mayor=Integer.MIN_VALUE;
for(int i=0; i<n; i++){
valores[i]=sc.nextInt();
}
for(int i=0;... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<pair<int, int> > v;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int a;
cin >> a;
v.push_back({a, i});
}
sort(v.begin(), v.end());
for (int i = 0; i < n / 2; i++) {
cout << v[i].second << " " << v[n - i - 1].second << end... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int n;
int ma[120];
int vis[120];
int main() {
int i, j;
while (~scanf("%d", &n)) {
memset(vis, 0, sizeof(vis));
int sum = 0;
for (i = 1; i <= n; i++) {
scanf("%d", &ma[i]);
sum += ma[i];
}
int r = sum * 2 / n;
for (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... | import java.util.List;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
public class ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=[int(x) for x in input().split()]
b=[]
j=1
for i in a:
b.append((i,j))
j+=1
b.sort()
j=0
while j!=n/2:
print(b[j][1], b[n-j-1][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>
int main() {
int n, j, i, sum = 0, average;
int a[105];
int vis[105];
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
average = sum * 2 / n;
for (i = 1; i <= n; i++) vis[i] = 0;
for (i = 1; i <= n; i++) {
for (j = i + 1; j <= n; 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... | /*package whatever //do not write package name here */
import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.BigInteger;
public class GFG
{
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] a=new int[n+1];
int[] b=ne... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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(test):
n = int(input())
a = list(map(int, input().split()))
s = sum(a) * 2 // n
for i in range(n):
for j in range(i + 1, n):
if a[i] + a[j] == s:
print(i + 1, j + 1)
a[j] = 10 ** 10
break
t = 1
#t = int(input())
for _ in range... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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.Collection;
import java.util.Scanner;
import java.util.Set;
import java.util.HashMap;
import java.util.HashSet;
import java.util.stream.Stream;
import java.util.Map;
import java.util.Map.Ent... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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().split()
B = [0] * n
for i in range(len(A)):
A[i] = int(A[i])
B[i]=i
for i in range(n-1):
for j in range(i+1, n):
if A[i] > A[j]:
t=A[i]
A[i]=A[j]
A[j]=t
t=B[i]
B[i]=B[j]
B[j]=t
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... | #!/usr/bin/env python
#-*-coding:utf-8 -*-
import collections
n=int(input())>>1
M=collections.defaultdict(list)
s=0
for i,a in enumerate(map(int,input().split())):
M[a].append(1+i)
s+=a
s//=n
for a,d in M.items():
while d:
n-=1
print(d.pop(),M[s-a].pop())
if not n:break
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input(""))
li=list(map(int,input().split()[:n]))
t=sum(li)//(n/2)
l=len(li)
li1=[]
for i in range(l):
for j in range(l):
if i ==j or i in li1 or j in li1:
continue
elif (li[i]+li[j])==t:
print(f"{i+1} {j+1}")
li1.append(i)
li1.append(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... | # 701A: Cards
n = int(raw_input())
a = map(int, raw_input().split())
value = sum(a) / (n / 2)
for i in xrange(n):
for j in xrange(i + 1, n):
if a[i] + a[j] == value:
print i + 1, j + 1
a[j] = 0
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
pair<int, int> a[105];
for (int i = 1; i <= n; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a + 1, a + n + 1);
for (int i = 1, j = n; i < j; i++, j--)
cout << a[i].second << " " << a[j].second << "\n";
return 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 sys
#sys.stdin = open("input.in","r")
#sys.stdout = open("test.out","w")
n=int(input())
l1= list(map(int,input().split()))
l2 = sorted(l1)
for i in range(len(l1)//2):
q1 = l1.index(l2[i])
l1[q1]="N"
q2 = l1.index(l2[-i-1])
l1[q2]="N"
print(q1+1,q2+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;
long long getindex(long long arr[], long long num) {
long long i = 0;
while (1) {
if (arr[i] == num) {
arr[i] = -1;
return i;
}
i++;
}
}
int main() {
long long n;
cin >> n;
long long arr[n], arr2[n];
for (long long 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... | #include <bits/stdc++.h>
using namespace std;
pair<int, int> a[105];
int main() {
int n, t;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", &t);
a[i].first = t;
a[i].second = i + 1;
}
sort(a, a + n);
for (int i = 0; i < n / 2; ++i) {
printf("%d %d\n", a[i].second, a[n - 1 - i].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... | # #
# CodeForces
# Problem 701A
# Python 2
# #
# Number of cards
n = input()
# Card costs
a = map(int, raw_input().split())
sum_matrix = []
sum_matrix.append([])
def find_count(matrix, to_search):
places = []
used = []
i=0
while i<n:
j=0
while j<i:
if matrix[i][j]==to_sear... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | num=int(input())
arr=[int(x) for x in input().split()][:num]
s=sum(arr)
s_n=int(s/(num/2))
# print(s_n)
for i in range(0,len(arr)):
if(arr[i]==-1):
# print('skipped')
continue
else:
a=arr[i]
arr[i]=-1
b=arr.index(s_n-a)
arr[b]=-1
print(i+1,b+1)
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
const int nmax = 1e2 + 42;
int t[nmax], n, sum = 0;
bool p[nmax];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> t[i];
sum = sum + t[i];
}
for (int i = 0; i < n; i++)
if (p[i] == 0) {
for (int j = i + 1; j < n; j++)
if (p[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;
int compare(pair<int, int> a, pair<int, int> b) {
if (a.first < b.first)
return 1;
else
return 0;
}
int main() {
vector<pair<int, int>> p;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int q;
cin >> q;
p.push_back(make_pair(q, i));
}
so... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = map(int, raw_input().split())
p = range(1, n+1)
t = sorted(zip(a, p))
for i in xrange(n/2):
print t[i][1], t[n-i-1][1] |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
p=list(map(int,input().split()))
tam=[]
for item in p:
tam.append(item)
y=0
o=-1
ko=[]
tam.sort()
for x in range(n//2):
ko.append(p.index(tam[y])+1)
p[p.index(tam[y])]=-5555
ko.append(p.index(tam[o])+1)
p[p.index(tam[o])]=-7777
o-=1
y+=1
print(*ko)
ko=[] |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | """http://codeforces.com/problemset/problem/701/A"""
num_cards = int(input())
half = int(num_cards/2)
cards = list(enumerate([int(x) for x in input().split(' ')]))
sort_cards = sorted(cards, key=lambda x: x[1])
for i in range(half):
print(sort_cards[i][0]+1, sort_cards[num_cards-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=sorted(range(n),key=lambda v:a[v])
for i in range(n//2):print(b[i]+1,b[~i]+1) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
b.append([a[i], i + 1])
b.sort()
for i in range(n//2):
print(b[i][1], b[-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())
arr = map(int, raw_input().split())
arr2 = list(enumerate(arr))
arr2.sort(key=lambda x: x[1])
for i in xrange(N/2):
print arr2[i][0]+1, arr2[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... | import java.util.Scanner;
public class xo_mushaobs_dzmao {
public static void main(String arcs[]) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int[] cards = new int[num];
int mean = 0;
boolean[] used = new boolean[num];
for(int i=0; i<num; i++) {
cards[i] = sc.nextInt();
mean ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
string = input().split(' ')
for i in range(n):
string[i] = int(string[i])
target = int(sum(string)/(n/2))
result = []
for i in range(n):
if not i in result:
result.append(i)
remaining = target - string[i]
for j in range(n):
if string[j] == remaining:
if not j in result... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 print_pairs(numbers):
target = sum(numbers)//(len(numbers)/2)
value_to_indices = {}
for i in range(len(numbers)):
if (target - numbers[i]) in value_to_indices and len(value_to_indices[target - numbers[i]]) > 0:
index = value_to_indices[target - numbers[i]].pop()
print(str... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool check(vector<pair<int, int>> &arr, int point) {
for (auto item : arr) {
if (point >= item.first and point <= item.second) {
return false;
}
}
return true;
}
void solve() {
int n;
cin >> n;
vector<pair<int, int>> arr(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())
arr=list(map(int,input().split()))
arr=list(enumerate(arr))
arr=sorted(arr,key=lambda x:x[1])
for i in range(len(arr)//2):
print(arr[i][0]+1,arr[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())
l = list(map( int , input().split() ))
arr = l.copy()
arr.sort()
j=0
k=n-1
for i in range(n//2):
x = l.index(arr[j])
l.remove(arr[j])
l.insert(x,0)
y = l.index(arr[k])
l.remove(arr[k])
l.insert(y,0)
print(x+1, y+1 )
j = j+1
k = k-1 |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.*;
import java.util.*;
public class cards
{
public static void main(String[] args) throws IOException
{
sc.init(System.in);
int n = sc.nextInt();
int[] cd = new int[n];
int sum = 0;
for(int i=0;i<n;i++)
{
cd[i]=sc.nextInt();
sum+=cd[i];
}
int req = sum/(n/2);
//System.ou... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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 arr[n];
int isk = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
isk += arr[i];
}
int iskom = isk / (n / 2);
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
if (arr[i] + arr[j] == iskom) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
l = list(map(int, input().split()))
s = int(sum(l) / n * 2)
tmp = list()
for i in range(n):
a = l[i]
l[i] = 0
if a > 0:
b = l.index(s - a)
print(i + 1, l.index(s - a) + 1)
l[l.index(s - a)] = 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... | from ctypes import *
n=int (raw_input())
a=map(int,raw_input().split())
sign=[]
sum=0
for i in range(n):
sum=sum+a[i]
sign.append(1)
num=sum/(n/2)
x=0
for i in range(n):
if sign[i]!=1:
continue
for j in range(i+1,n):
if num-a[j]==a[i] and sign[j]==1:
print i+1,j+1
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | def find(n):
global d
for item in d:
if d[item]==n:
index = item
del d[index]
return index
n = input()
arr = map(int,raw_input().split())
su = 2*sum(arr)/n
d = {}
for i in range(n):
d[i] = arr[i]
for i in range(n):
temp = 0
for it in arr:
temp = it
# print tem... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
byte n = sc.nextByte();
byte a[] = new byte[n];
int sum = 0;
for (byte 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a;
cin >> n;
vector<pair<int, int> > v(n + 1);
for (int i = 1; i < n + 1; i++) {
cin >> a;
v[i] = make_pair(a, i);
}
sort(v.begin() + 1, v.end());
for (int i = 1; i <= n / 2; i++) {
cout << v[i].second << " " << v[n + 1 - i].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 = input()
num = [ int(i) for i in raw_input().split() ]
tot = sum(num)
x = (tot/(n/2))
hs = []
for i in xrange(101):
hs += [ [] ]
for i in xrange(1,n+1):
hs[num[i-1]]+=[i]
for i in xrange(101):
while(len(hs[i])!=0):
x1 = hs[i].pop(0)
y1 = hs[x-i].pop(0)
print x1,y1
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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())
ns = sorted(enumerate(map(int, input().split())), key=lambda x: x[1])
for i in range(n // 2):
print(ns[i][0] + 1, ns[n - i - 1][0] + 1) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int n, number, mx = -1, mn = 1000;
int arr[105];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> number;
mx = max(mx, number);
mn = min(mn, number);
arr[i] = number;
}
int sum = mx + mn;
for (int i = 0; i < n; i++) {
int num = arr[i... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()))
sa = sum(a)/(n/2)
b = []
for i in range(len(a)):
for j in range(len(a)):
if i != j:
if a[i] + a[j] == sa:
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... | if __name__ == '__main__':
n = int(input())
arr = list(map(int,input().split()))
av = int((sum(arr)/n) *2)
for i in range(n):
if arr[i] != 0:
for j in range(n):
if arr[i] + arr[j] == av and i != j:
print(i+1,j+1)
arr[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()))
b = sorted([a[i], i + 1] for i in range(n))
for i in range(n // 2):
print(b[i][1], b[-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())
Y=sorted(zip(map(int,input().split()),range(1,1+n)))
for i in range(n>>1):print(Y[i][1],Y[-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())
arr = list(map(int,input().split()))
s = sum(arr)//(n//2)
memo = {i:False for i in range(n)}
for i in range(n):
if memo[i] == False:
for j in range(i+1,n):
if memo[j] == False and arr[j] == s - arr[i]:
memo[j] = True
memo[i] = True
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def 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... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] a = new int[n];
int i, j, k = 0;
for (i = 0; i < n; i++) {
a[i] = scanner.nextInt();
k += a... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<int> v(n);
for (int i = 0; i < n; i++) {
scanf("%d", &v[i]);
}
int minVal = *min_element(v.begin(), v.end());
int maxVal = *max_element(v.begin(), v.end());
int sum = minVal + maxVal;
int visited[n];
memset... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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[200];
int main() {
int n, aa, ss, i, sum;
scanf("%d", &n);
vector<int> v[101];
sum = 0;
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
v[a[i]].push_back(i + 1);
sum += a[i];
}
aa = sum * 2 / n;
while (n) {
for (i = 0; i <= 100 && 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())
mas = list(map(int,input().split()))
s = sum(mas)/(n/2)
mmi = []
mmj = []
for i in range(n):
for j in range(n):
if i != j and mas[i] + mas[j] == s :
c = 0
for k in range(len(mmi)):
if j == mmj[k] or ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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()))
s=min(cards)+max(cards)
for i in range(n):
if cards[i]!=0:
val=cards[i]
cards[i]=0
pos=cards.index(s-val)
cards[pos]=0
print(str(i+1)+" "+str(pos+1)) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
a = map(int,raw_input().split(' '))
b = []
for i in range(n):
b.append((a[i],i))
b.sort(key=lambda x:x[0])
for i in range(n/2):
print b[i][1]+1,b[-(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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, 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=[]
k=max(a)
l=min(a)
m=k+l
for i in range(n):
if a[i]!=0:
for j in range(i+1,n):
if a[i]+a[j]==m:
c=[i+1,j+1]
b.append(c)
a[j]=0
break
if len(b)==n//2:
break
for i in b:
print(i[0],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()))
s = sum(a)//(n//2)
for i in range(n):
for j in range(i+1,n):
if a[i]+a[j] == s:
print(i+1,j+1)
a[j]=0
break |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(raw_input())
cards = list(map(int, raw_input().split()))
tuples = [ (card, i + 1) for i, card in enumerate(cards) ]
tuples.sort()
for i in range(n // 2):
print('%d %d' % (tuples[i][1], tuples[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... | from sys import stdin
N = int(raw_input())
i = 0
a = []
sum = 0
a = map(int, stdin.readline().split(' '))
while i < N:
sum += a[i]
i+=1
sum = sum/(N/2)
j = 0
i = 0
while j < N/2:
while i < N:
if a[i] > 0:
break
i+=1
k = i+1
while k < N and (a[k] < 0 or a[k]+a[i] != sum):
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n = int(input())
a = list(map(int, input().split()))
a = list(zip(a, range(1, n + 1)))
a.sort()
for i in range(n>>1):
print("{0} {1}".format(a[i][1], a[-i-1][1])) |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.util.Scanner;
public class Main {
Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
new Main();
}
public Main() {
new A().doIt();
}
class A{
void doIt(){
int n = sc.nextInt();
int a[] = 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... | read = lambda: map(int, input().split())
n = int(input())
a = list(read())
a = [(a[i], i + 1) for i in range(n)]
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... | #include <bits/stdc++.h>
struct card {
int a, b;
} c[50];
int main() {
int n, i, j, a[100], av, sum = 0, k = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
av = sum / (n / 2);
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
if (a[i] + a[j] == av) {
... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
static BufferedReader in;
static PrintWriter out;
static StringTokenizer buffer;
public static void solve() {
int ... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Cards
{
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.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... | //701A : CARDS
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;
//Yo... |
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
list1=list(map(int,input().split()))
list2=list1+[]
list2.sort()
for i in range(0,n//2):
p=list1.index(list2[i])
list1[p]=-1
q=list1.index(list2[n-i-1])
list1[q]=-1
print(p+1,q+1)
|
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to distribute cards such that the sum of values written of the cards... | n=int(input())
a=list(map(int,input().split()))
avg=int((sum(a)/n)*2)
l=[]
for i in range(n):
for j in range(n):
if i!=j and a[j]!=0:
if a[i]+a[j]==avg and ((i+1) not in l) and (j+1) not in l:
a[j]==0
l.append(i+1)
l.append(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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, n, a[101], sum = 0, r[101], re[101], k = 1;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
sum /= (n / 2);
for (i = 1; i < n; i++) {
r[k] = i;
for (j = 1; j <= n; j++) {
if (i == j) continue;
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(raw_input())
cards = [int(x) for x in raw_input().split()]
cards = [(cards[i], i + 1) for i in xrange(n)]
cards.sort()
for i in xrange(n / 2):
print cards[i][1], cards[-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())
data = sorted([(v, i) for i, v in enumerate(map(int, input().split()))])
for i in range(n // 2):
print(data[i][1] + 1, data[-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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, i;
cin >> n;
pair<int, int> p[n];
for (i = 0; i < n; i++) {
cin >> a;
p[i].first = a;
p[i].second = i + 1;
}
sort(p, p + n);
for (i = 0; i < n / 2; i++) {
cout << p[i].second << " " << p[n - 1 - i].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.util.Arrays;
import java.util.*;
public class NewMain12 {
public static void main(String[] args) {
// TODO code application logic here
Scanner s = new Scanner(System.in);
int x = s.nextInt();
card[] hm = new card[x];
for (int i = 0; i < x; i++) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.