message stringlengths 2 20.1k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 1.95k 109k | cluster float64 17 17 | __index_level_0__ int64 3.91k 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two tea... | instruction | 0 | 11,336 | 17 | 22,672 |
Tags: brute force
Correct Solution:
```
from itertools import permutations
a = [int(x) for x in input().split()]
for p in permutations(a):
if p[0] + p[1] + p[2] == p[3] + p[4] + p[5]:
print('YES')
exit()
print('NO')
``` | output | 1 | 11,336 | 17 | 22,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two tea... | instruction | 0 | 11,337 | 17 | 22,674 |
Tags: brute force
Correct Solution:
```
def f(a, b):
if (len(a) == 6):
#print(a);
x = sum(a[0:3]);
y = sum(a[3:6]);
if (x == y):
return True
else:
for i in range(len(b)):
x = b[i]
j = i + 1
k = len(b)
... | output | 1 | 11,337 | 17 | 22,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two tea... | instruction | 0 | 11,338 | 17 | 22,676 |
Tags: brute force
Correct Solution:
```
a = list(map(int, input().split()))
if sum(a) % 2 == 1:
print('NO')
else:
target = sum(a) // 2
n = 6
ans = 'NO'
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if a[i] + a[j] + a[k] == target:
ans = 'YES'
print(ans)
`... | output | 1 | 11,338 | 17 | 22,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two tea... | instruction | 0 | 11,339 | 17 | 22,678 |
Tags: brute force
Correct Solution:
```
l = list(map(int, input().split()))
y = False
s = sum(l)
i = 0
while i < 4 and not y:
j = i + 1
while j < 5 and not y:
k = j + 1
while k < 6 and not y:
t = l[i] + l[j] + l[k]
if t == s - t:
y = True
k += 1
j += 1
i += 1
if y:
print("YES")
else:
print("NO... | output | 1 | 11,339 | 17 | 22,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two tea... | instruction | 0 | 11,340 | 17 | 22,680 |
Tags: brute force
Correct Solution:
```
A=list(map(int,input().split()))
flag=False
for i in range(6):
pow1=A[i]
used1=[i]
for j in range(6):
if j not in used1:
pow2=pow1+A[j]
used2=used1+[j]
for k in range(6):
if k not in used2:
... | output | 1 | 11,340 | 17 | 22,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to partici... | instruction | 0 | 11,341 | 17 | 22,682 |
Yes | output | 1 | 11,341 | 17 | 22,683 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to partici... | instruction | 0 | 11,342 | 17 | 22,684 |
Yes | output | 1 | 11,342 | 17 | 22,685 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to partici... | instruction | 0 | 11,343 | 17 | 22,686 |
Yes | output | 1 | 11,343 | 17 | 22,687 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to partici... | instruction | 0 | 11,344 | 17 | 22,688 |
Yes | output | 1 | 11,344 | 17 | 22,689 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to partici... | instruction | 0 | 11,345 | 17 | 22,690 |
No | output | 1 | 11,345 | 17 | 22,691 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to partici... | instruction | 0 | 11,346 | 17 | 22,692 |
No | output | 1 | 11,346 | 17 | 22,693 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to partici... | instruction | 0 | 11,347 | 17 | 22,694 |
No | output | 1 | 11,347 | 17 | 22,695 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to partici... | instruction | 0 | 11,348 | 17 | 22,696 |
No | output | 1 | 11,348 | 17 | 22,697 |
Provide a correct Python 3 solution for this coding contest problem.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points)... | instruction | 0 | 11,539 | 17 | 23,078 |
"Correct Solution:
```
def getScore(d):
return int(d[1]) * 3 + int(d[3])
isFirst = True
while 1:
n = int(input())
if n == 0:
break
if not isFirst:
print()
table = []
for i in range(0,n):
d = list(_ for _ in input().split())
score = getScore(d)
table.... | output | 1 | 11,539 | 17 | 23,079 |
Provide a correct Python 3 solution for this coding contest problem.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points)... | instruction | 0 | 11,540 | 17 | 23,080 |
"Correct Solution:
```
f = True
while True:
n = int(input())
if n == 0:
break
T = []
for i in range(n):
name,w,l,d = list(input().split())
T.append((name,i,int(w)*3+int(d)))
if f: f = False
else: print()
for i in sorted(T, key = lambda x:(-x[2],x[1])):
print(i... | output | 1 | 11,540 | 17 | 23,081 |
Provide a correct Python 3 solution for this coding contest problem.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points)... | instruction | 0 | 11,541 | 17 | 23,082 |
"Correct Solution:
```
flag = True
while True:
n = int(input())
if n == 0: break
answer = {}
for _ in range(n):
result = input().split()
country = result[0]
win, lose, draw = map(int, result[1:])
score = win * 3 + draw
answer[country] = score
if flag:
... | output | 1 | 11,541 | 17 | 23,083 |
Provide a correct Python 3 solution for this coding contest problem.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points)... | instruction | 0 | 11,542 | 17 | 23,084 |
"Correct Solution:
```
b=False
while True:
n = int(input())
if n==0:break
d=dict()
if b:print()
b=True
for _ in range(n):
line = input().split()
tmp = int(line[1])*3+int(line[3]*1)
if tmp in d:
d[tmp].append(line[0])
else:
d[tmp] = []
... | output | 1 | 11,542 | 17 | 23,085 |
Provide a correct Python 3 solution for this coding contest problem.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points)... | instruction | 0 | 11,543 | 17 | 23,086 |
"Correct Solution:
```
import bisect
cnt = 0
while 1:
outs = []
outn = []
n = int(input())
if n == 0: break
elif cnt > 0: print()
names = []
scores = []
for i in range(n):
line = list(input().split())
name = line[0]
names.append(name)
w = line[1]
l... | output | 1 | 11,543 | 17 | 23,087 |
Provide a correct Python 3 solution for this coding contest problem.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points)... | instruction | 0 | 11,544 | 17 | 23,088 |
"Correct Solution:
```
f = True
while True:
n = int(input())
if n == 0: break
tbl = []
for i in range(n):
name, w, l, d = list(input().split())
tbl.append([name, i, 3*int(w)+int(d)])
if f: f = False
else: print()
for i in sorted(tbl, key=lambda x:(-x[2],x[1])): print(i[0], ',... | output | 1 | 11,544 | 17 | 23,089 |
Provide a correct Python 3 solution for this coding contest problem.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points)... | instruction | 0 | 11,545 | 17 | 23,090 |
"Correct Solution:
```
st=True
while True:
n=int(input())
if n==0:
break
if st==False:
print()
team={}
for _ in range(n):
data=input().split(" ")
team[data[0]]=3*int(data[1])+int(data[3])
team=team.items()
team=sorted(team,key=lambda w:w[1],reverse=True)
... | output | 1 | 11,545 | 17 | 23,091 |
Provide a correct Python 3 solution for this coding contest problem.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points)... | instruction | 0 | 11,546 | 17 | 23,092 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0124
"""
import sys
from operator import itemgetter
def solve(data):
result = []
for name, win, lose, draw in data:
score = win * 3 + draw * 1
result.append([name, score])
result.sor... | output | 1 | 11,546 | 17 | 23,093 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the po... | instruction | 0 | 11,547 | 17 | 23,094 |
Yes | output | 1 | 11,547 | 17 | 23,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the po... | instruction | 0 | 11,548 | 17 | 23,096 |
Yes | output | 1 | 11,548 | 17 | 23,097 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the po... | instruction | 0 | 11,549 | 17 | 23,098 |
Yes | output | 1 | 11,549 | 17 | 23,099 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the po... | instruction | 0 | 11,550 | 17 | 23,100 |
Yes | output | 1 | 11,550 | 17 | 23,101 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the po... | instruction | 0 | 11,551 | 17 | 23,102 |
No | output | 1 | 11,551 | 17 | 23,103 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the po... | instruction | 0 | 11,552 | 17 | 23,104 |
No | output | 1 | 11,552 | 17 | 23,105 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the po... | instruction | 0 | 11,553 | 17 | 23,106 |
No | output | 1 | 11,553 | 17 | 23,107 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the po... | instruction | 0 | 11,554 | 17 | 23,108 |
No | output | 1 | 11,554 | 17 | 23,109 |
Provide a correct Python 3 solution for this coding contest problem.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples... | instruction | 0 | 11,581 | 17 | 23,162 |
"Correct Solution:
```
def solve():
def measurement(a, b, w):
a_root = root[a]
b_root = root[b]
if a_root != b_root:
a_member = member[a_root]
b_member = member[b_root]
offset = w - (weight[b] - weight[a])
if len(a_member) > len(b_member):
... | output | 1 | 11,581 | 17 | 23,163 |
Provide a correct Python 3 solution for this coding contest problem.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples... | instruction | 0 | 11,582 | 17 | 23,164 |
"Correct Solution:
```
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**13
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... | output | 1 | 11,582 | 17 | 23,165 |
Provide a correct Python 3 solution for this coding contest problem.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples... | instruction | 0 | 11,583 | 17 | 23,166 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
class WeightedUnionFind():
def __init__(self,N):
self.N = N
self.parents = [-1] * self.N
self.diff_weight = [0] * self.N
def find(self,x):
if self.parents[x] < 0:
... | output | 1 | 11,583 | 17 | 23,167 |
Provide a correct Python 3 solution for this coding contest problem.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples... | instruction | 0 | 11,584 | 17 | 23,168 |
"Correct Solution:
```
class WeightedUnionFind(object):
__slots__ = ["nodes", "weight"]
def __init__(self, n: int) -> None:
self.nodes = [-1]*n
self.weight = [0]*n
def get_root(self, x: int) -> int:
if x < 0:
raise ValueError("Negative Index")
if self.nodes[x] ... | output | 1 | 11,584 | 17 | 23,169 |
Provide a correct Python 3 solution for this coding contest problem.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples... | instruction | 0 | 11,585 | 17 | 23,170 |
"Correct Solution:
```
class Value_UnionFind():
def __init__(self,n):
self.par = [i for i in range(n)]
self.differ_weight = [0] * n
self.rank = [0] * n
def root(self,x):
if x == self.par[x]:
return x
r = self.root(self.par[x])
self.differ_weight[x] +... | output | 1 | 11,585 | 17 | 23,171 |
Provide a correct Python 3 solution for this coding contest problem.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples... | instruction | 0 | 11,586 | 17 | 23,172 |
"Correct Solution:
```
def solve():
def measurement(a, b, w):
a_root = root[a]
b_root = root[b]
if a_root != b_root:
a_member = member[a_root]
b_member = member[b_root]
offset = w - (weight[b] - weight[a])
if len(a_member) > len(b_member):
... | output | 1 | 11,586 | 17 | 23,173 |
Provide a correct Python 3 solution for this coding contest problem.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples... | instruction | 0 | 11,587 | 17 | 23,174 |
"Correct Solution:
```
def solve():
def measurement(a, b, w):
a_root = root[a]
b_root = root[b]
if a_root != b_root:
a_member = member[a_root]
b_member = member[b_root]
offset = w - (weight[b] - weight[a])
if len(a_member) > len(b_member):
... | output | 1 | 11,587 | 17 | 23,175 |
Provide a correct Python 3 solution for this coding contest problem.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples... | instruction | 0 | 11,588 | 17 | 23,176 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10 ** 5)
# 連結性の確認
class UnionFind():
def __init__(self, n):
self.parents = list(range(n))
self.weight = [0] * n
self.rank = [0] * n
def find(self, a):
if self.parents[a] == a:
return a
p = self.find(sel... | output | 1 | 11,588 | 17 | 23,177 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference ... | instruction | 0 | 11,589 | 17 | 23,178 |
Yes | output | 1 | 11,589 | 17 | 23,179 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference ... | instruction | 0 | 11,590 | 17 | 23,180 |
Yes | output | 1 | 11,590 | 17 | 23,181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference ... | instruction | 0 | 11,591 | 17 | 23,182 |
Yes | output | 1 | 11,591 | 17 | 23,183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference ... | instruction | 0 | 11,592 | 17 | 23,184 |
Yes | output | 1 | 11,592 | 17 | 23,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference ... | instruction | 0 | 11,593 | 17 | 23,186 |
No | output | 1 | 11,593 | 17 | 23,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference ... | instruction | 0 | 11,594 | 17 | 23,188 |
No | output | 1 | 11,594 | 17 | 23,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference ... | instruction | 0 | 11,595 | 17 | 23,190 |
No | output | 1 | 11,595 | 17 | 23,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference ... | instruction | 0 | 11,596 | 17 | 23,192 |
No | output | 1 | 11,596 | 17 | 23,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n boxers, the weight of the i-th boxer is a_i. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer numb... | instruction | 0 | 11,698 | 17 | 23,396 |
Tags: greedy, sortings
Correct Solution:
```
def max_team(n, weights):
weights.sort(reverse=True)
prev_weights = 10000000000
ans = 0
for i in range(n):
curr_weights = weights[i]
if curr_weights + 1 < prev_weights:
ans += 1
prev_weights = curr_weights + 1
e... | output | 1 | 11,698 | 17 | 23,397 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n boxers, the weight of the i-th boxer is a_i. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer numb... | instruction | 0 | 11,699 | 17 | 23,398 |
Tags: greedy, sortings
Correct Solution:
```
def int_multiple():
return [int(c) for c in input().split()]
def int_single():
return int(input())
def str_multiple():
return [c for c in input().split()]
def str_single():
return input()
# start
n = int_single()
l = int_multiple()
l = sorted(l)
team =... | output | 1 | 11,699 | 17 | 23,399 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n boxers, the weight of the i-th boxer is a_i. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer numb... | instruction | 0 | 11,700 | 17 | 23,400 |
Tags: greedy, sortings
Correct Solution:
```
n = int(input())
nums = [int(x) for x in input().split()]
nums = sorted(nums, reverse=True)
cnt = 1
cur = nums[0]+1
for x in nums[1:]:
if x + 1 < cur:
cur = x+1
cnt += 1
elif x + 1 == cur:
cur = x
cnt += 1
elif x == cur and x !=... | output | 1 | 11,700 | 17 | 23,401 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n boxers, the weight of the i-th boxer is a_i. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer numb... | instruction | 0 | 11,701 | 17 | 23,402 |
Tags: greedy, sortings
Correct Solution:
```
n=int(input())
arr=list(map(int,input().split(" ")))
arr.sort()
arr[n-1]+=1
#print(arr)
for i in range(n-2,-1,-1):
if(arr[i+1]-arr[i]==1):
continue
if(arr[i+1]-arr[i]>1):
arr[i]+=1
elif(i>0 and arr[i-1]!=arr[i]):
if(arr[i]!=1):
arr[i]-=1
elif(arr[i]>1 and i==0):... | output | 1 | 11,701 | 17 | 23,403 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n boxers, the weight of the i-th boxer is a_i. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer numb... | instruction | 0 | 11,702 | 17 | 23,404 |
Tags: greedy, sortings
Correct Solution:
```
n = int(input())
A = list(map(int, input().split()))
A.sort()
MAX_WEIGHT = 150001
k = 0
count = 0
for i in range(1, MAX_WEIGHT+1):
if k >= len(A):
break
boxer = A[k]
if i < boxer - 1:
i += boxer - 2
continue
while i > boxer + 1 and... | output | 1 | 11,702 | 17 | 23,405 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.