wrong_submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 131k
1.05M
| wrong_status
stringclasses 2
values | wrong_cpu_time
float64 10
40k
| wrong_memory
float64 2.94k
3.37M
| wrong_code_size
int64 1
15.5k
| problem_description
stringlengths 1
4.75k
| wrong_code
stringlengths 1
6.92k
| acc_submission_id
stringlengths 10
10
| acc_status
stringclasses 1
value | acc_cpu_time
float64 10
27.8k
| acc_memory
float64 2.94k
960k
| acc_code_size
int64 19
14.9k
| acc_code
stringlengths 19
14.9k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s951878789
|
p02694
|
u646892595
| 2,000 | 1,048,576 |
Wrong Answer
| 22 | 9,168 | 101 |
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x = int(input())
a = 100
ans = 0
while a <= x:
a += a*0.01
a = int(a)
ans += 1
print(ans)
|
s982611771
|
Accepted
| 23 | 9,160 | 100 |
x = int(input())
a = 100
ans = 0
while a < x:
a += a*0.01
a = int(a)
ans += 1
print(ans)
|
s307921593
|
p03719
|
u628965061
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 64 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a,b,c=map(int,input().split())
print("Yes" if c<=a<=b else 'No')
|
s475992151
|
Accepted
| 17 | 2,940 | 64 |
a,b,c=map(int,input().split())
print("Yes" if a<=c<=b else 'No')
|
s405645625
|
p03478
|
u711238850
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 202 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
def decsum(i):
ans = 0
while(i==0):
ans+=i%10
i//=10
return ans
n,a,b = tuple(map(int,input().split()))
ans = 0
for i in range(1,n+1):
t = decsum(i)
if a<=t<=b:
ans+=1
print(ans)
|
s209608168
|
Accepted
| 25 | 2,940 | 208 |
def decsum(i):
ans = 0
while(i>0):
ans+=i%10
i//=10
return ans
n,a,b = tuple(map(int,input().split()))
ans = 0
for i in range(1,n+1):
t = decsum(i)
if a<=t and t<=b:
ans+=i
print(ans)
|
s023665367
|
p03478
|
u902151549
| 2,000 | 262,144 |
Wrong Answer
| 47 | 5,044 | 516 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
# coding: utf-8
import time
import re
import math
import fractions
def main():
N,A,B=map(int,input().split())
count=0
for a in range(1,N+1):
s=str(a)
total=0
for b in s:
total+=int(b)
if A<=total and total<=B:
count+=1
print(count)
start=time.time()
main()
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
|
s212347203
|
Accepted
| 48 | 5,044 | 516 |
# coding: utf-8
import time
import re
import math
import fractions
def main():
N,A,B=map(int,input().split())
count=0
for a in range(1,N+1):
s=str(a)
total=0
for b in s:
total+=int(b)
if A<=total and total<=B:
count+=a
print(count)
start=time.time()
main()
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
|
s756180526
|
p03645
|
u046592970
| 2,000 | 262,144 |
Wrong Answer
| 766 | 49,796 | 336 |
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
|
n,m = map(int,input().split())
lis1 = []
lis2 = []
ans = "IMPOSSIBLE"
for i in range(m):
a,b = map(int,input().split())
if a == 1:
lis1.append(b)
else:
lis2.append((a,b))
lis2 = set(lis2)
for j in lis1:
if (j,n) in lis2:
ans = "POSSIBLE"
else:
pass
print(lis1,lis2)
print(ans)
|
s948596211
|
Accepted
| 645 | 42,288 | 320 |
n,m = map(int,input().split())
lis1 = []
lis2 = []
ans = "IMPOSSIBLE"
for i in range(m):
a,b = map(int,input().split())
if a == 1:
lis1.append(b)
else:
lis2.append((a,b))
lis2 = set(lis2)
for j in lis1:
if (j,n) in lis2:
ans = "POSSIBLE"
else:
pass
print(ans)
|
s287015165
|
p00003
|
u343251190
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,724 | 202 |
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
|
n = int(input())
for i in range(n):
a = list(map(int, input().split()))
m = max(a)
b = sum([i**2 for i in a if i != m])
if (m**2 == b):
print("Yes")
else:
print("No")
|
s315657733
|
Accepted
| 50 | 7,632 | 202 |
n = int(input())
for i in range(n):
a = list(map(int, input().split()))
m = max(a)
b = sum([i**2 for i in a if i != m])
if (m**2 == b):
print("YES")
else:
print("NO")
|
s132351361
|
p03545
|
u328751895
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 1,104 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
nums = list(map(int, input()))
ans_map = {}
for i in range(3):
if i == 0:
ans_map['-'] = nums[0] - nums[1]
ans_map['+'] = nums[0] + nums[2]
continue
for operators in dict.fromkeys(ans_map):
tmp_val = ans_map[operators]
if i == 2:
if tmp_val + nums[i + 1] == 7:
print('{}{}{}{}{}{}{}'.format(
nums[0],
operators[0],
nums[1],
operators[1],
nums[2],
'+',
nums[3]
))
break
if tmp_val - nums[i + 1] == 7:
print('{}{}{}{}{}{}{}'.format(
nums[0],
operators[0],
nums[1],
operators[1],
nums[2],
'-',
nums[3]
))
break
ans_map[operators + '-'] = tmp_val - nums[i + 1]
ans_map[operators + '+'] = tmp_val + nums[i + 1]
del ans_map[operators]
|
s958107017
|
Accepted
| 17 | 3,064 | 1,129 |
nums = list(map(int, input()))
ans_map = {}
for i in range(3):
if i == 0:
ans_map['+'] = nums[0] + nums[1]
ans_map['-'] = nums[0] - nums[1]
continue
for operators in dict.fromkeys(ans_map):
tmp_val = ans_map[operators]
if i == 2:
if tmp_val + nums[i + 1] == 7:
print('{}{}{}{}{}{}{}=7'.format(
nums[0],
operators[0],
nums[1],
operators[1],
nums[2],
'+',
nums[3]
))
break
if tmp_val - nums[i + 1] == 7:
print('{}{}{}{}{}{}{}=7'.format(
nums[0],
operators[0],
nums[1],
operators[1],
nums[2],
'-',
nums[3]
))
break
continue
ans_map[operators + '+'] = tmp_val + nums[i + 1]
ans_map[operators + '-'] = tmp_val - nums[i + 1]
del ans_map[operators]
|
s282531793
|
p03543
|
u148551245
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 108 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
n = str(input(()))
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
print("Yes")
else:
print("No")
|
s561643984
|
Accepted
| 17 | 2,940 | 110 |
n = str(input())
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
print("Yes")
else:
print("No")
|
s755860742
|
p03644
|
u569776981
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,206 | 8,928 | 166 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N = int(input())
x = 0
a = []
for i in range(N):
while i % 2 == 0:
i //= 2
x += 1
a.append(x)
x = 0
a = sorted(a)
a = a[::-1]
print(a[0])
|
s382360311
|
Accepted
| 28 | 9,132 | 80 |
N = int(input())
x = 1
while x <= N:
x *= 2
print(x // 2)
|
s418875824
|
p02396
|
u297342993
| 1,000 | 131,072 |
Wrong Answer
| 130 | 6,724 | 107 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
c = 0
while True:
x = int(input())
if(x == 0):
break;
print('Case {0}: {1}'.format(c,x))
c += 1
|
s572468488
|
Accepted
| 130 | 6,720 | 107 |
c = 1
while True:
x = int(input())
if(x == 0):
break;
print('Case {0}: {1}'.format(c,x))
c += 1
|
s994521185
|
p03644
|
u934529721
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 249 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
num = int(input())
print(num)
if num == 1:
print(1)
elif num == 2 | 3:
print(2)
elif 4 <= num <= 7:
print(4)
elif 8 <= num <= 15:
print(8)
elif 16 <= num <= 31:
print(16)
elif 32 <= num <= 63:
print(32)
else:
print(64)
|
s728999206
|
Accepted
| 17 | 3,060 | 237 |
num = int(input())
if num == 1:
print(1)
elif num == 2 | 3:
print(2)
elif 4 <= num <= 7:
print(4)
elif 8 <= num <= 15:
print(8)
elif 16 <= num <= 31:
print(16)
elif 32 <= num <= 63:
print(32)
else:
print(64)
|
s270983076
|
p03448
|
u055875839
| 2,000 | 262,144 |
Wrong Answer
| 48 | 3,060 | 240 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
coin500 = int(input())
coin100 = int(input())
coin050 = int(input())
target = int(input())
x = 0
for a in range(coin500):
for b in range(coin100):
for c in range (coin050):
if target == a * 500 + b * 100 + c * 50:x += 1
print(x)
|
s741617145
|
Accepted
| 53 | 3,060 | 247 |
coin500 = int(input())
coin100 = int(input())
coin050 = int(input())
target = int(input())
x = 0
for a in range(coin500+1):
for b in range(coin100+1):
for c in range (coin050+1):
if target == a * 500 + b * 100 + c * 50:x += 1
print(x)
|
s395541365
|
p02833
|
u130492706
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 190 |
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
if n % 2 == 1:
print(0)
else:
c = 0
s = 0
while 5**c < n:
s += n // 5**c
c += 1
print(s)
|
s778165411
|
Accepted
| 17 | 2,940 | 201 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
if n % 2 == 1:
print(0)
else:
c = 1
s = 0
while 2 * 5**c <= n:
s += n // (2 * 5**c)
c += 1
print(s)
|
s001478889
|
p03719
|
u320763652
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 94 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a,b,c = map(int, input().split())
if a <= c and c <=b:
print("YES")
else:
print("NO")
|
s417465124
|
Accepted
| 17 | 2,940 | 94 |
a,b,c = map(int, input().split())
if a <= c and c <=b:
print("Yes")
else:
print("No")
|
s486866519
|
p03369
|
u543954314
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 35 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
s = input()
print(700+s.count("o"))
|
s545955206
|
Accepted
| 18 | 2,940 | 41 |
s = input()
print(700 + s.count("o")*100)
|
s602201621
|
p03693
|
u608726540
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 87 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r,g,b=map(int,input().split())
if 10*g+b %4==0:
print('YES')
else:
print('NO')
|
s508997524
|
Accepted
| 17 | 2,940 | 88 |
r,g,b=map(int,input().split())
if (10*g+b)%4==0:
print('YES')
else:
print('NO')
|
s600045009
|
p02606
|
u811068179
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,088 | 100 |
How many multiples of d are there among the integers between L and R (inclusive)?
|
l,r,d = (int(i) for i in input().split())
z = int(r/d-l/d)
if l%d == 0:
print(z+1)
else:
print(z)
|
s967125945
|
Accepted
| 30 | 9,148 | 136 |
import math
l,r,d = (int(i) for i in input().split())
z = int(math.floor(r/d)-math.floor(l/d))
if l%d == 0:
print(z+1)
else:
print(z)
|
s048287259
|
p03089
|
u859897687
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 152 |
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
n=int(input())
m=list(map(int,input().split()))
a=1
for i in range(n):
if not m[i]<=i+1:
a=0
if a==1:
for i in m:
print(i)
else:
print(-1)
|
s232254207
|
Accepted
| 17 | 3,060 | 288 |
n=int(input())
m=list(map(int,input().split()))
ans=[]
for i in range(n):
for j in range(n-1-i,-1,-1):
if not m[j]==j+1:
continue
#m[j]==j
ans.append(j+1)
m=m[:j]+m[j+1:]
break
if not len(m)==0:
print(-1)
else:
for i in range(n):
print(ans[n-1-i])
|
s882781724
|
p03378
|
u811730180
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 172 |
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
|
n, m, x = map(int, input().split())
fee = map(int, input().split())
ls = list(range(n+1))
f, b = ls[:x], ls[x+1:]
print(min(len(set(fee) & set(f)), len(set(fee) & set(b))))
|
s808577502
|
Accepted
| 17 | 3,060 | 167 |
n, m, x = map(int, input().split())
fee = set(map(int, input().split()))
ls = list(range(n+1))
f, b = ls[:x], ls[x+1:]
print(min(len(fee & set(f)), len(fee & set(b))))
|
s157165750
|
p03567
|
u439176910
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 334 |
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
data = input()
tmp = data.replace("x", "")
c1 , c2, num = 0, -1, 0
if tmp == tmp[::-1]:
while(c1 < len(data) + c2):
if data[c1] == data[c2]:
c1+=1
c2-=1
elif data[c2]=="x":
c2-=1
num+=1
else:
c1+=1
num+=1
else:
num = -1
print(num)
|
s678003912
|
Accepted
| 20 | 3,060 | 90 |
data = input()
print("Yes" if "AC" in [data[i:i+2] for i in range(len(data)-1)] else "No")
|
s876014398
|
p02743
|
u389910364
| 2,000 | 1,048,576 |
Wrong Answer
| 233 | 14,644 | 706 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor
import numpy as np
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
a, b, c = list(map(int, sys.stdin.buffer.readline().split()))
ok = math.sqrt(a) + math.sqrt(b) < math.sqrt(c)
if ok:
print('Yes')
else:
print('No')
|
s078398836
|
Accepted
| 52 | 5,712 | 424 |
import os
import sys
from decimal import Decimal
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
a, b, c = list(map(int, sys.stdin.buffer.readline().split()))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
ok = Decimal.sqrt(a) + Decimal.sqrt(b) < Decimal.sqrt(c)
if ok:
print('Yes')
else:
print('No')
|
s666721511
|
p03587
|
u461833298
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 24 |
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem is not accepted. How many problems prepared by Snuke are accepted to be used in the contest?
|
S = input()
S.count('1')
|
s778242020
|
Accepted
| 17 | 2,940 | 31 |
S = input()
print(S.count('1'))
|
s514535544
|
p03671
|
u182765930
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 87 |
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
a, b, c = map(int, input().split())
s = [a, b, c]
m = min(s)
s.remove(m)
print(sum(s))
|
s073776654
|
Accepted
| 17 | 2,940 | 86 |
a, b, c = map(int, input().split())
s = [a, b, c]
m = max(s)
s.remove(m)
print(sum(s))
|
s322518436
|
p03997
|
u503228842
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 67 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print(h*(a+b)/2)
|
s239153657
|
Accepted
| 18 | 2,940 | 72 |
a = int(input())
b = int(input())
h = int(input())
print(int(h*(a+b)/2))
|
s141702443
|
p02261
|
u072053884
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,520 | 612 |
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
n = int(input())
cards_b = input().split()
cards_s = list(cards_b)
for i in range(n):
for j in range(n - 1, i, -1):
if int(cards_b[j][1]) < int(cards_b[j - 1][1]):
cards_b[j], cards_b[j - 1] = cards_b[j - 1], cards_b[j]
#SelectionSort
for i in range(n):
min_i = i
for j in range(i, n):
if int(cards_s[j][1]) < int(cards_s[min_i][1]):
min_i = j
cards_s[i], cards_s[min_i] = cards_s[min_i], cards_s[i]
print(" ".join(cards_b))
print("Stable")
print(" ".join(cards_s))
if cards_b == cards_s:
print("Stable")
else:
print("Not Stable")
|
s758286642
|
Accepted
| 60 | 7,612 | 612 |
n = int(input())
cards_b = input().split()
cards_s = list(cards_b)
for i in range(n):
for j in range(n - 1, i, -1):
if int(cards_b[j][1]) < int(cards_b[j - 1][1]):
cards_b[j], cards_b[j - 1] = cards_b[j - 1], cards_b[j]
#SelectionSort
for i in range(n):
min_i = i
for j in range(i, n):
if int(cards_s[j][1]) < int(cards_s[min_i][1]):
min_i = j
cards_s[i], cards_s[min_i] = cards_s[min_i], cards_s[i]
print(" ".join(cards_b))
print("Stable")
print(" ".join(cards_s))
if cards_b == cards_s:
print("Stable")
else:
print("Not stable")
|
s449877699
|
p02578
|
u909224749
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 33,620 | 165 |
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
sum_step = 0
for n in range(1, N):
max_ = max(A[0:n])
sum_step += max_ - A[n]
print(sum_step)
|
s002609406
|
Accepted
| 152 | 33,604 | 185 |
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
sum_step = 0
for n in range(1,N):
if A[n] < A[n-1]:
sum_step += A[n-1] - A[n]
A[n] = A[n-1]
print(sum_step)
|
s270466129
|
p02600
|
u658905620
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,184 | 274 |
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
|
X=int(input('X='))
if 400<=X<=599:
print(8)
elif 600<=X<=799:
print(7)
elif 800<=X<=999:
print(6)
elif 1000<=X<=1199:
print(5)
elif 1200<=X<=1399:
print(4)
elif 1400<=X<=1599:
print(3)
elif 1600<=X<=1799:
print(2)
elif 1800<=X<=1999:
print(1)
|
s736305311
|
Accepted
| 31 | 9,184 | 270 |
X=int(input())
if 400<=X<=599:
print(8)
elif 600<=X<=799:
print(7)
elif 800<=X<=999:
print(6)
elif 1000<=X<=1199:
print(5)
elif 1200<=X<=1399:
print(4)
elif 1400<=X<=1599:
print(3)
elif 1600<=X<=1799:
print(2)
elif 1800<=X<=1999:
print(1)
|
s473454097
|
p02854
|
u482157295
| 2,000 | 1,048,576 |
Wrong Answer
| 91 | 26,220 | 354 |
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
|
num = int(input())
num_list = list(map(int,input().split()))
ans = sum(num_list)//2
#numl = sum(num_list[:num//2])
#numr = sum(num_list[num//2:num])
#print(ans,numl,numr)
total = 0
flag = "off"
for i in range(num):
total += num_list[i]
if total >= ans:
n1 = total - num_list[i]
n2 = total
break
#print(n1,n2)
print(min((n2-ans),(ans-n1)))
|
s112688711
|
Accepted
| 100 | 27,300 | 489 |
import math
num = int(input())
num_list = list(map(int,input().split()))
ans = sum(num_list)/2
#numl = sum(num_list[:num//2])
#numr = sum(num_list[num//2:num])
#print(ans,numl,numr)
total = 0
flag = "off"
for i in range(num):
total += num_list[i]
if total >= ans:
#print(ans)
if ans -(total - num_list[i]) < total - ans:
ans = ans -(total - num_list[i])
else:
ans = total - ans
break
#print(n1,n2)
#print(min((n2-ans),(ans-n1)))
print(math.ceil(ans*2))
|
s195780395
|
p03644
|
u770308589
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,220 | 267 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N = int(input())
answer = 0
count = 0
answer_num = 0
for num in range(N+1):
calnum = num
while (num % 2 == 0) and num != 0 :
count += 1
num = num /2
if(count > answer):
answer = count
answer_num = calnum
print(answer_num)
|
s053979192
|
Accepted
| 29 | 8,984 | 88 |
N = int(input())
count = 0
while N > 1:
N = int(N/2)
count += 1
print(2**count)
|
s900028349
|
p03556
|
u174273188
| 2,000 | 262,144 |
Wrong Answer
| 38 | 2,940 | 160 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
def resolve():
n = int(input())
for i in range(n, 1, -1):
if i ** 0.5 % 1 == 0:
return i
if __name__ == "__main__":
resolve()
|
s197577457
|
Accepted
| 17 | 2,940 | 109 |
def resolve():
n = int(input())
print(int(n ** 0.5) ** 2)
if __name__ == "__main__":
resolve()
|
s832596923
|
p02613
|
u694536861
| 2,000 | 1,048,576 |
Wrong Answer
| 155 | 16,296 | 285 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
s_i = []
for i in range(n):
s = input()
s_i.append(s)
ac = s_i.count('AC')
wa = s_i.count('WA')
tle = s_i.count('TLE')
re = s_i.count('RE')
print("AC × {0}".format(ac))
print("WA × {0}".format(wa))
print("TLE × {0}".format(tle))
print("RE × {0}".format(re))
|
s542032459
|
Accepted
| 152 | 16,292 | 281 |
n = int(input())
s_i = []
for i in range(n):
s = input()
s_i.append(s)
ac = s_i.count('AC')
wa = s_i.count('WA')
tle = s_i.count('TLE')
re = s_i.count('RE')
print("AC x {0}".format(ac))
print("WA x {0}".format(wa))
print("TLE x {0}".format(tle))
print("RE x {0}".format(re))
|
s868615191
|
p03860
|
u666964944
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 25 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
print('A'+input()[0]+'C')
|
s903061180
|
Accepted
| 17 | 2,940 | 42 |
l = input().split()
print('A'+l[1][0]+'C')
|
s459540495
|
p03795
|
u672898046
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 82 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
a = int(input())
if a < 15:
print(800*a)
else:
b = a-15
print(800*a - 200*b)
|
s083187666
|
Accepted
| 17 | 2,940 | 48 |
a = int(input())
b = a //15
print(800*a - 200*b)
|
s190402811
|
p03371
|
u780269042
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 199 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a,b,c,x,y = map(int, input().split())
price = a*x+b*c
if x>y:
price_a = c*(x-y)*2 + a*(x-y)
else:
price_a = c*(y-x)*2 + b*(y-x)
if price > price_a:
print(price_a)
else:
print(price)
|
s449029296
|
Accepted
| 17 | 2,940 | 143 |
A, B, AB, X, Y = map(int, input().split())
AB *= 2
result = [A*X+B*Y, AB*max(X,Y), AB*Y+A*(X-Y) if X>Y else AB*X+B*(Y-X)]
print(min(result))
|
s668718514
|
p00001
|
u580227385
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,532 | 135 |
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
if __name__ == '__main__':
a = [1819, 2003, 876, 2840, 1723, 1673, 3776, 2848, 1592, 922]
print(sorted(a, reverse=True)[1:4])
|
s543881033
|
Accepted
| 20 | 5,604 | 100 |
num = [int(input()) for i in range(10)]
num.sort(reverse=True)
for i in range(3):
print(num[i])
|
s382939948
|
p03050
|
u121732701
| 2,000 | 1,048,576 |
Wrong Answer
| 443 | 3,060 | 145 |
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
|
N = int(input())
count = 0
X = 0
q = 1
while N >= X:
if N%q==0 and N/q-1<N:
count += N/q-1
q += 1
X = (q+1)*q+q
print(count)
|
s388455768
|
Accepted
| 405 | 3,060 | 163 |
N = int(input())
count = 0
X = 0
q = 1
while N >= X:
if N%q==0 and N/q-1<N and N/q-1!=1:
count += N/q-1
q += 1
X = (q+1)*q+q
print(int(count))
|
s299830062
|
p02614
|
u797572808
| 1,000 | 1,048,576 |
Wrong Answer
| 402 | 9,364 | 1,258 |
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
h,w,k = map(int,input().split())
import copy
ar = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
ar[i] = list(input())
print(ar)
d = {}
for i in range(h):
for j in range(w):
d[(i+1,j+1)] = ar[i][j]
print(d)
sm = 0
for i in d.values():
if(i == "#"):
sm += 1
gl = sm - k
print("gl",gl)
ans = 0
def ch_red(x):
d_tmp = copy.deepcopy(d)
#print(d_tmp)
cnt = 0
x_ar_bin = [0 for _ in range(h+w)]
v = h+w
for i in range(h+w):
x_ar_bin[i] = int(bin(x >> i),2)%2
#print(x_ar_bin)
for i in range(h):
if(x_ar_bin[i] == 0):
continue
else:
for j in range(w):
key = (i+1,j+1)
if(d_tmp[key] == "#"):
d_tmp[key] = "$"
cnt += 1
for i in range(h,h+w):
if(x_ar_bin[i] == 0):
continue
else:
for j in range(h):
key = (j+1,i+1-h)
if(d_tmp[key] == "#"):
d_tmp[key] = "$"
cnt += 1
if(cnt == gl):
return 1
else:
return 0
#print(cnt)
mx = 2**(h+w)
print(mx)
for i in range(mx):
ans += ch_red(i)
print(ans)
|
s565736780
|
Accepted
| 408 | 9,352 | 1,262 |
h,w,k = map(int,input().split())
import copy
ar = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
ar[i] = list(input())
#print(ar)
d = {}
for i in range(h):
for j in range(w):
d[(i+1,j+1)] = ar[i][j]
#print(d)
sm = 0
for i in d.values():
if(i == "#"):
sm += 1
gl = sm - k
#print("gl",gl)
ans = 0
def ch_red(x):
d_tmp = copy.deepcopy(d)
#print(d_tmp)
cnt = 0
x_ar_bin = [0 for _ in range(h+w)]
v = h+w
for i in range(h+w):
x_ar_bin[i] = int(bin(x >> i),2)%2
#print(x_ar_bin)
for i in range(h):
if(x_ar_bin[i] == 0):
continue
else:
for j in range(w):
key = (i+1,j+1)
if(d_tmp[key] == "#"):
d_tmp[key] = "$"
cnt += 1
for i in range(h,h+w):
if(x_ar_bin[i] == 0):
continue
else:
for j in range(h):
key = (j+1,i+1-h)
if(d_tmp[key] == "#"):
d_tmp[key] = "$"
cnt += 1
if(cnt == gl):
return 1
else:
return 0
#print(cnt)
mx = 2**(h+w)
#print(mx)
for i in range(mx):
ans += ch_red(i)
print(ans)
|
s324023738
|
p03493
|
u826771152
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 326 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
def shift_only(n,array):
tmp = []
counter = 0
while True:
flag = True
for num in array:
if num%2 != 0:
flag = False
if flag == False:
break
array = [i/2 for i in array]
counter +=1
return counter
|
s675289981
|
Accepted
| 17 | 2,940 | 102 |
string = input()
counter = 0
for ele in string:
if ele == "1":
counter += 1
print(counter)
|
s824137284
|
p03828
|
u496687522
| 2,000 | 262,144 |
Wrong Answer
| 39 | 3,064 | 357 |
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
|
N = int(input())
insu_list = [[2, 0]]
ans = 1
for i in range(N):
n = i+1
for j in range(len(insu_list)):
while n % insu_list[j][0] == 0:
n /=insu_list[j][0]
insu_list[j][1] += 1
if n != 1:
insu_list.append([n, 1])
print(insu_list)
for i in range(len(insu_list)):
ans *= insu_list[i][1] + 1
print(ans)
|
s575326690
|
Accepted
| 39 | 3,064 | 350 |
N = int(input())
insu_list = [[2, 0]]
ans = 1
for i in range(N):
n = i+1
for j in range(len(insu_list)):
while n % insu_list[j][0] == 0:
n /=insu_list[j][0]
insu_list[j][1] += 1
if n != 1:
insu_list.append([n, 1])
for i in range(len(insu_list)):
ans *= insu_list[i][1] + 1
print(ans%(10**9+7))
|
s356494482
|
p03494
|
u197078193
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 177 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = list(map(int,input().split()))
flag = True
n = 0
while flag:
for a in A:
if a%2 == 1:
flag = False
A = [int(a/2) for a in A]
n += 1
print(n)
|
s128587252
|
Accepted
| 18 | 2,940 | 178 |
N = int(input())
A = list(map(int,input().split()))
flag = True
n = -1
while flag:
for a in A:
if a%2 == 1:
flag = False
A = [int(a/2) for a in A]
n += 1
print(n)
|
s975413843
|
p03854
|
u018976119
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,316 | 273 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S=input()
n=len(S)
while n>0:
print(S)
if S[n-4:n+1]=='dream':
n-=5
elif S[n-4:n+1]=='erase':
n-=5
elif S[n-6:n+1]=='dreamer':
n-=7
elif S[n-5:n+1]=='eraser':
n-=6
else:
print('NO')
exit()
print('YES')
|
s552471122
|
Accepted
| 29 | 3,188 | 252 |
S=input()
n=len(S)
while n>0:
if S[n-5:n]=='dream':
n-=5
elif S[n-5:n]=='erase':
n-=5
elif S[n-7:n]=='dreamer':
n-=7
elif S[n-6:n]=='eraser':
n-=6
else:
print('NO')
exit()
print('YES')
|
s551955129
|
p02398
|
u896065593
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,576 | 189 |
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
|
a, b, c = map(int, input().split())
divisorsCount = 0
divideNum = a
for var in range(a, b):
if c % divideNum == 0:
divisorsCount += 1
divideNum += 1
print(divisorsCount)
|
s335884471
|
Accepted
| 20 | 7,648 | 184 |
a, b, c = map(int, input().split())
DivisorCount = 0
DivideNum = a
for var in range(a, b+1):
if c % DivideNum == 0:
DivisorCount += 1
DivideNum += 1
print(DivisorCount)
|
s694785514
|
p03360
|
u794173881
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 115 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a,b,c = map(int,input().split())
k = int(input())
print(max(a,b,c)**k + min(a,b,c) + (a+b+c-max(a,b,c)-min(a,b,c)))
|
s086558121
|
Accepted
| 17 | 3,060 | 119 |
a,b,c = map(int,input().split())
k = int(input())
print(max(a,b,c)*(2**k) + min(a,b,c) + (a+b+c-max(a,b,c)-min(a,b,c)))
|
s531017602
|
p03730
|
u222207357
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 185 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
A, B, C = map(int,input().split())
flag = False
for i in range(1,B):
dec = i*A%B
if dec == C:
flag = True
break
if flag:
print('Yes')
else:
print('No')
|
s622366431
|
Accepted
| 17 | 2,940 | 185 |
A, B, C = map(int,input().split())
flag = False
for i in range(1,B):
dec = i*A%B
if dec == C:
flag = True
break
if flag:
print('YES')
else:
print('NO')
|
s825987329
|
p02841
|
u575297711
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 86 |
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
b_day = input()
d_day = input()
print('0') if d_day.split(" ")[1] == 1 else print('1')
|
s405701295
|
Accepted
| 17 | 2,940 | 109 |
m0, d0 = map(int, input().split())
m1, d1 = map(int, input().split())
print('0') if m0 == m1 else print('1')
|
s655585544
|
p02275
|
u404682284
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 635 |
Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail: Counting-Sort(A, B, k) 1 for i = 0 to k 2 do C[i] = 0 3 for j = 1 to length[A] 4 do C[A[j]] = C[A[j]]+1 5 /* C[i] now contains the number of elements equal to i */ 6 for i = 1 to k 7 do C[i] = C[i] + C[i-1] 8 /* C[i] now contains the number of elements less than or equal to i */ 9 for j = length[A] downto 1 10 do B[C[A[j]]] = A[j] 11 C[A[j]] = C[A[j]]-1 Write a program which sorts elements of given array ascending order based on the counting sort.
|
def CountingSort(n, input_line, max_num):
max_num += 1
count_list = [0 for i in range(max_num)]
output_line = [0 for i in range(n)]
for i in range(n):
count_list[input_line[i]] += 1
for i in range(1,max_num):
count_list[i] = count_list[i] + count_list[i-1]
print(count_list)
for i in range(n-1,-1, -1):
output_line[count_list[input_line[i]]-1] = input_line[i]
count_list[input_line[i]] -= 1
return output_line
n = int(input())
input_line = [int(i) for i in input().split()]
max_num = max(input_line)
output_line = CountingSort(n, input_line, max_num)
print(output_line)
|
s413355665
|
Accepted
| 2,460 | 235,676 | 628 |
def CountingSort(n, input_line, max_num):
max_num += 1
count_list = [0 for i in range(max_num)]
output_line = [0 for i in range(n)]
for i in range(n):
count_list[input_line[i]] += 1
for i in range(1,max_num):
count_list[i] = count_list[i] + count_list[i-1]
for i in range(n-1,-1, -1):
output_line[count_list[input_line[i]]-1] = str(input_line[i])
count_list[input_line[i]] -= 1
return output_line
n = int(input())
input_line = [int(i) for i in input().split()]
max_num = max(input_line)
output_line = CountingSort(n, input_line, max_num)
print(' '.join(output_line))
|
s210350942
|
p04043
|
u027675217
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 92 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a,b,c = map(int,input().split())
sum = a+b+c
if sum == 17:
print("Yes")
else:
print("No")
|
s061081600
|
Accepted
| 17 | 2,940 | 111 |
a = list(map(int, input().split()))
if a.count(5) == 2 and a.count(7) == 1:
print("YES")
else:
print("NO")
|
s117310890
|
p03556
|
u055941944
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,060 | 142 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
# -*- coding utf-8 -*-
n=int(input())
ans=[]
for i in range(1,n+1,1):
z=i**0.5
if z%1==0:
ans.append(z)
print(round(z**2))
|
s631188833
|
Accepted
| 30 | 2,940 | 117 |
n=int(input())
ans=0
for i in range(10**5):
x=i**2
if n>=x:
ans=x
else:
break
print(ans)
|
s200028838
|
p03731
|
u329706129
| 2,000 | 262,144 |
Wrong Answer
| 318 | 25,196 | 344 |
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it. How long will the shower emit water in total?
|
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
ans = T
wait = 0
start = 0
for i in range(1, N):
print(wait)
if (t[i] - t[i - 1] >= T):
ans += wait + T
start = t[i]
wait = 0
else:
if (wait > T):
ans, wait = ans + T, wait - T
wait = t[i] - start
print(ans+wait)
|
s399467104
|
Accepted
| 187 | 25,196 | 142 |
N, T = map(int, input().split())
t = [int(i) for i in input().split()]
ans = T
for i in range(0, N-1):
ans += min(t[i+1]-t[i],T)
print(ans)
|
s144203791
|
p03351
|
u131405882
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 200 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a, b, c, d = map(int,input().split())
if abs(a-c) < d or ((abs(c-b) < d and abs(b-a) < d) and (a<b and b<c)) or((abs(c-b) < d and abs(b-a) < d) and (a>b and b>c)) :
print('Yes')
else:
print('No')
|
s188593355
|
Accepted
| 17 | 3,060 | 209 |
a, b, c, d = map(int,input().split())
if abs(a-c) <= d or ((abs(c-b) <= d and abs(b-a) <= d) and (a<=b and b<=c)) or((abs(c-b) <= d and abs(b-a) <= d) and (a>=b and b>=c)) :
print('Yes')
else:
print('No')
|
s970082579
|
p03795
|
u635974378
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,316 | 40 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
print(n*800-200*n//15)
|
s906049203
|
Accepted
| 17 | 2,940 | 42 |
n = int(input())
print(n*800-200*(n//15))
|
s531477703
|
p03455
|
u122944896
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 100 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a,b = map(int,input().split())
c = (a * b) / 2
if c == 0 :
print("Even")
else:
print("Odd")
|
s142079953
|
Accepted
| 17 | 2,940 | 109 |
a,b = (int(x) for x in input().split())
c = (a * b) % 2
if c == 0 :
print("Even")
else:
print("Odd")
|
s312320183
|
p03493
|
u779602548
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,316 | 148 |
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
# -*- coding: utf-8 -*-
from collections import Counter
n = Counter(list(map(int,input().split())))
print(n[1])
|
s584564407
|
Accepted
| 20 | 2,940 | 104 |
# -*- coding: utf-8 -*-
a,b,c = map(int,list(input()))
print(a+b+c)
|
s035650777
|
p03827
|
u314050667
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 61 |
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
n = int(input())
s = input()
print(s.count("I")-s.count("D"))
|
s609758793
|
Accepted
| 17 | 2,940 | 102 |
n = int(input())
s = input()
print(max([s[:i].count("I")-s[:i].count("D") for i in range(1,n+1)]+[0]))
|
s819493217
|
p03853
|
u396391104
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 116 |
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
h,w = map(int,input().split())
c = [list(input().split())for i in range(h)]
for i in range(2*h):
print(c[i//2])
|
s201987665
|
Accepted
| 17 | 3,060 | 117 |
h,w = map(int,input().split())
c = [list(input().split())for i in range(h)]
for i in range(2*h):
print(*c[i//2])
|
s651436486
|
p02614
|
u814271993
| 1,000 | 1,048,576 |
Wrong Answer
| 56 | 9,092 | 434 |
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
import itertools
h,w,n=map(int, input().split())
l=[str(input())for _ in range(h)]
ans = 0
for i in list(itertools.product([0,1], repeat= h)):
for j in list(itertools.product([0,1], repeat= w)):
b = 0
for k in range(h):
for m in range(w):
if i[k] == 0 and j[m] == 0 and l[k][m] == '#':
b +=1
if b == n:
ans += 1
print(ans)
print(ans)
|
s136242463
|
Accepted
| 61 | 9,200 | 445 |
from itertools import groupby, accumulate, product, permutations, combinations
h,w,k = map(int, input().split())
l = [input() for i in range(h)]
ans = 0
for i in product([0,1],repeat=h):
for j in product([0,1],repeat=w):
Ans = 0
for m in range(h):
for n in range(w):
if l[m][n] == '#' and i[m] == 1 and j[n] == 1:
Ans += 1
if Ans == k:
ans +=1
print(ans)
|
s332179172
|
p03378
|
u411923565
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,036 | 179 |
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
|
import bisect
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
ans_N = (N+1) - bisect.bisect_left(A, X)
ans_0 = bisect.bisect_left(A,X)
print(min(ans_N,ans_0))
|
s923723560
|
Accepted
| 24 | 9,184 | 174 |
import bisect
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
ans_N = M - bisect.bisect_left(A,X)
ans_0 = bisect.bisect_left(A,X)
print(min(ans_N,ans_0))
|
s273345744
|
p02255
|
u831244171
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 418 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
n = int(input())
lst = list(map(int,input().split()))
def pri(lst):
for i in range(len(lst)-1):
print(lst[i],end=" ")
print(lst[-1])
for i in range(1,n):
v = lst[i]
j = i-1
while True:
if j < 0:
lst[0] = v
break
if lst[j] > v:
lst[j+1] = lst[j]
j -= 1
else:
lst[j+1] = v
break
pri(lst)
|
s423637954
|
Accepted
| 20 | 5,604 | 372 |
def insertsort(array):
for i in range(1,len(array)):
print(" ".join(list(map(str,array))))
temp = array[i]
j = i-1
while j >= 0 and temp < array[j]:
array[j+1] = array[j]
j -= 1
array[j+1] = temp
return array
input()
a = insertsort(list(map(int,input().split())))
print(" ".join(list(map(str,a))))
|
s349234655
|
p02422
|
u279605379
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,464 | 323 |
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
|
str = input()
q = int(input())
for i in range(q):
s = input().split(" ")
cmd,a,b = s[0],int(s[1]),int(s[2])
if(cmd=="print"):
print(str[a:b+1])
elif(cmd=="reverse"):
str = str[:a]+str[a:b+1][::-1]+str[b+1:]
print(str)
else:
str = str[:a]+s[3]+str[b+1:]
print(str)
|
s818711329
|
Accepted
| 20 | 7,624 | 285 |
str = input()
q = int(input())
for i in range(q):
s = input().split(" ")
cmd,a,b = s[0],int(s[1]),int(s[2])
if(cmd=="print"):
print(str[a:b+1])
elif(cmd=="reverse"):
str = str[:a]+str[a:b+1][::-1]+str[b+1:]
else:
str = str[:a]+s[3]+str[b+1:]
|
s639114655
|
p04043
|
u957799665
| 2,000 | 262,144 |
Wrong Answer
| 27 | 8,984 | 190 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
n_5 = 0
n_7 = 0
a = map(int, input().split())
for i in a:
if i == 5:
n_5 += 1
elif i == 7:
n_7 += 1
if n_5 == 2 and n_7 == 1:
print("yes")
else:
print("No")
|
s726172732
|
Accepted
| 31 | 9,100 | 190 |
n_5 = 0
n_7 = 0
a = map(int, input().split())
for i in a:
if i == 5:
n_5 += 1
elif i == 7:
n_7 += 1
if n_5 == 2 and n_7 == 1:
print("YES")
else:
print("NO")
|
s569291641
|
p03555
|
u273242084
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 95 |
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
C1 = list(input())
C2 = list(input())
if C1 == C2[::-1]:
print("Yes")
else:
print("No")
|
s368156101
|
Accepted
| 17 | 2,940 | 95 |
C1 = list(input())
C2 = list(input())
if C1 == C2[::-1]:
print("YES")
else:
print("NO")
|
s653839243
|
p02260
|
u279605379
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,604 | 408 |
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
|
#ALDS1_2-B Sort 1 - Selection Sort
def selectionSort(A,N):
c=0
for i in range(N):
minj = i
j=i
while j<N:
if(int(A[j])<int(A[minj])):
minj = j
j+=1
A[i],A[minj]=A[minj],A[i]
c+=1
return c
N=int(input())
A=input().split()
c=selectionSort(A,N)
S=""
for i in range(N-1):
S+=A[i]+" "
S+=str(A[-1])
print(S)
print(c)
|
s369663549
|
Accepted
| 20 | 7,720 | 437 |
#ALDS1_2-B Sort 1 - Selection Sort
def selectionSort(A,N):
c=0
for i in range(N):
minj = i
j=i
while j<N:
if(int(A[j])<int(A[minj])):
minj = j
j+=1
if(i!=minj):
A[i],A[minj]=A[minj],A[i]
c+=1
return c
N=int(input())
A=input().split()
c=selectionSort(A,N)
S=""
for i in range(N-1):
S+=A[i]+" "
S+=str(A[-1])
print(S)
print(c)
|
s686687753
|
p03360
|
u393512980
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 83 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a,b,c=map(int,input().split())
k=int(input())
print(a+b+c-max(a,b,c)+max(a,b,c)**k)
|
s705799511
|
Accepted
| 17 | 2,940 | 86 |
a,b,c=map(int,input().split())
k=int(input())
print(a+b+c-max(a,b,c)+max(a,b,c)*2**k)
|
s894845323
|
p03503
|
u054106284
| 2,000 | 262,144 |
Wrong Answer
| 118 | 3,064 | 572 |
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods. There are already N stores in the street, numbered 1 through N. You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2. Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}. Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.
|
N = int(input())
F = []
P = []
for i in range(N):
temp = [int(i) for i in input().split()]
tt = 0b0
for j in range(len(temp)):
tt += 2 ** j * temp[j]
print(bin(tt))
F.append(tt)
for i in range(N):
temp = [int(i) for i in input().split()]
P.append(temp)
def bene(bit):
res = 0
for i in range(N):
a = bit & F[i]
cc = 0
for j in str(bin(a)):
if j == "1":
cc += 1
res += P[i][cc]
return res
benes = [bene(i) for i in range(1,1024)]
benes.sort()
print(benes[-1])
|
s784604610
|
Accepted
| 124 | 3,064 | 553 |
N = int(input())
F = []
P = []
for i in range(N):
temp = [int(i) for i in input().split()]
tt = 0b0
for j in range(len(temp)):
tt += 2 ** j * temp[j]
F.append(tt)
for i in range(N):
temp = [int(i) for i in input().split()]
P.append(temp)
def bene(bit):
res = 0
for i in range(N):
a = bit & F[i]
cc = 0
for j in str(bin(a)):
if j == "1":
cc += 1
res += P[i][cc]
return res
benes = [bene(i) for i in range(1,1024)]
benes.sort()
print(benes[-1])
|
s054813168
|
p03474
|
u834832056
| 2,000 | 262,144 |
Wrong Answer
| 23 | 9,172 | 220 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
a, b = map(int, input().split())
s = input()
ans = True
for (i, char) in enumerate(s):
if i == a:
ans = char == '-'
else:
ans = type(char) is int
if ans:
print('yes')
else:
print('no')
|
s097918511
|
Accepted
| 25 | 9,092 | 377 |
a, b = map(int, input().split())
s = input()
ans = True
for (i, char) in enumerate(s):
if i == a:
if char == '-':
ans = True
else:
ans = False
break
else:
try:
ans = type(int(char)) is int
except:
ans = False
break
if ans:
print('Yes')
else:
print('No')
|
s134417394
|
p04029
|
u332253305
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 62 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n=int(input())
sum=0
for i in range(n):
sum+=i;
print(sum)
|
s517414534
|
Accepted
| 17 | 2,940 | 65 |
n=int(input())
sum=0
for i in range(n+1):
sum += i;
print(sum)
|
s692600074
|
p03861
|
u250734103
| 2,000 | 262,144 |
Wrong Answer
| 32 | 9,120 | 65 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = list(map(int, input().split()))
print(b // x - a // x)
|
s593562839
|
Accepted
| 29 | 9,156 | 71 |
a, b, x = list(map(int, input().split()))
print(b // x - (a - 1) // x)
|
s186639598
|
p02975
|
u193927973
| 2,000 | 1,048,576 |
Wrong Answer
| 2,105 | 21,644 | 704 |
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
|
n = int(input())
a = list(map(int, input().split()))
if n%3!=0:
print("No")
else:
bina = []
maxketa=0
for i in range(len(a)):
bina.append(format(a[i], 'b'))
if maxketa<len(bina[i]):
maxketa=len(bina[i])
flag=1
for i in range(maxketa):
onecount=0
for j in range(len(bina)):
k = i-maxketa+len(bina[j])
print(k)
if k>=0:
if bina[j][k]=="1":
onecount+=1
print(onecount)
if len(bina)*2/3!=onecount:
if onecount!=0:
flag=0
print("No")
break
if flag==1:
print("Yes")
|
s644349051
|
Accepted
| 64 | 20,424 | 517 |
N=int(input())
A=list(map(int,input().split()))
if A.count(0)==N:
print("Yes")
elif N%3!=0:
print("No")
elif len(set(A))==2:
if 0 in set(A):
if A.count(0)==N/3:
print("Yes")
else:
print("No")
else:
print("No")
elif len(set(A))==3:
xor=0
for a in set(A):
if A.count(a)==N/3:
xor^=a
else:
print("No")
exit()
if xor==0:
print("Yes")
else:
print("No")
else:
print("No")
|
s149136173
|
p03139
|
u021548497
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,004 | 59 |
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
n,a,b=map(int,input().split());print(min(a,b),min(0,a+b-n))
|
s051314876
|
Accepted
| 30 | 8,992 | 59 |
n,a,b=map(int,input().split());print(min(a,b),max(0,a+b-n))
|
s119422734
|
p03719
|
u632369368
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 105 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
A, B, C = [int(n) for n in input().split()]
if C >= A and C <= B:
print('YES')
else:
print('NO')
|
s554036364
|
Accepted
| 17 | 2,940 | 105 |
A, B, C = [int(n) for n in input().split()]
if C >= A and C <= B:
print('Yes')
else:
print('No')
|
s818005440
|
p02234
|
u657361950
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 465 |
The goal of the matrix-chain multiplication problem is to find the most efficient way to multiply given $n$ matrices $M_1, M_2, M_3,...,M_n$. Write a program which reads dimensions of $M_i$, and finds the minimum number of scalar multiplications to compute the maxrix-chain multiplication $M_1M_2...M_n$.
|
import sys
def get_min_cost(n, p):
m = [[0 for x in range(n+1)] for x in range(n+1)]
for s in range(n):
i = 1
for j in range(s+2, n):
m[i][j] = sys.maxsize
for k in range(i, j+1):
m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
i+=1
return m[1][n]
n = int(input())
p = [0] * (n+1)
j = 0
for i in range(n):
a = list(map(int, input().split()))
if i == 0:
p[j] = a[0]
j += 1
p[j] = a[1]
j += 1
print(get_min_cost(n, p))
|
s517157797
|
Accepted
| 120 | 5,668 | 428 |
def mcm(p,n):
m=[[0 for x in range(n+1)] for x in range(n+1)]
for s in range(n):
for i,j in zip(range(1,n+1),range(s+2,n+1)):
m[i][j] = 1 << 30
for k in range(i,j):
m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
return m[1][n]
n=int(input())
p=[0]*(n+1)
for i in range(n-1):
t=list(map(int,input().split()))
p[i]=t[0];
t=list(map(int,input().split()))
p[n-1]=t[0]
p[n]=t[1]
ans=mcm(p,n)
print(ans)
|
s317627361
|
p03471
|
u903959844
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,064 | 459 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
NY = input().split()
N_Y = [int(s)for s in NY]
counter_Y = 0
counter = 0
listx = []
for i in range(N_Y[0]):
for j in range(N_Y[0]):
for k in range(N_Y[0]):
counter_Y = 10000 * i + 5000 * j + 1000 * k
if counter_Y == N_Y[1] and i+j+k <= N_Y[0]:
listx = [i,j,k]
counter += 1
print(counter)
if counter == 0:
print("-1 -1 -1")
else:
print("{} {} {}".format(listx[0],listx[1],listx[2]))
|
s289677892
|
Accepted
| 1,943 | 3,064 | 419 |
NY = input().split()
N_Y = [int(s)for s in NY]
counter_Y = 0
counter = 0
listx = []
for i in range(N_Y[0]+1):
for j in range(N_Y[0]+1):
k = N_Y[0] - i - j
counter_Y = 10000 * i + 5000 * j + 1000 * k
if counter_Y == N_Y[1] and k >= 0:
listx = [i,j,k]
counter += 1
if counter == 0:
print("-1 -1 -1")
else:
print("{} {} {}".format(listx[0],listx[1],listx[2]))
|
s007329719
|
p03067
|
u374240707
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 86 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
x, y, z = map(int, input().split())
print('Yes') if x <= y and y <= z else print('No')
|
s874247668
|
Accepted
| 17 | 2,940 | 91 |
x, y, z = map(int, input().split())
print('Yes') if (x - z) * (y - z) < 0 else print('No')
|
s811579377
|
p00100
|
u428982301
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,784 | 498 |
There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list of data where each item includes the employee ID _i_ , the amount of sales _q_ and the corresponding unit price _p_. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that _n_ < 4000, and each employee has an unique ID. The unit price _p_ is less than or equal to 1,000,000 and the amount of sales _q_ is less than or equal to 100,000.
|
if __name__ == '__main__':
list = []
while (True):
n = int(input())
if (n == 0):
break
isNA = True
for i in range(n):
ds = input().split()
e = ds[0]
p = int(ds[1])
q = int(ds[2])
sales = p * q
if (1000000 <= sales):
list.append(e)
isNA = False
if isNA:
list.append("NA")
for l in list:
print("%s" % l)
|
s051628712
|
Accepted
| 30 | 5,776 | 501 |
while True:
no = {}
n = int(input())
if (n == 0):
break
for i in range(n):
datas = map(int, input().split())
li = list(datas)
e = li[0]
p = li[1]
q = li[2]
s = p * q
if (e not in no):
no[e] = s
else:
no[e] += s
na = True
for k in no.keys():
if (1000000 <= no[k]):
print(k)
na = False
if (na == True):
print("NA")
|
s091225009
|
p03643
|
u730710086
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 70 |
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
# -*- coding: <encoding name> -*-
n = int(input())
print("ABC" + 'n')
|
s148224280
|
Accepted
| 18 | 2,940 | 63 |
# -*- coding: <encoding name> -*-
n = input()
print("ABC" + n)
|
s585131561
|
p03495
|
u390901416
| 2,000 | 262,144 |
Wrong Answer
| 174 | 48,664 | 208 |
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
from collections import Counter
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
lenght = len(set(A))-K
if lenght<0:print(0)
else:print(len(Counter(A).most_common()[::-1][lenght:]))
|
s513191395
|
Accepted
| 200 | 48,640 | 258 |
from collections import Counter
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
lenght = len(set(A))-K
ans = 0
if lenght<=0:print(ans), exit()
else:
for k, v in Counter(A).most_common()[::-1][:lenght]:
ans += v
print(ans)
|
s952363676
|
p03644
|
u562016607
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N = int(input())
for i in range(7):
if 2**i < N and 2**i > N:
print(2**i)
break
|
s188671029
|
Accepted
| 17 | 2,940 | 95 |
N = int(input())
for i in range(7):
if 2**i <= N and 2**(i+1) > N:
print(2**i)
break
|
s698066861
|
p03455
|
u840310460
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 106 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int,input().split())
if a * b / 2 == 0:
print("Even")
else:
print("Odd")
|
s778622992
|
Accepted
| 17 | 2,940 | 90 |
a, b = map(int, input().split())
if a*b % 2 == 0:
print("Even")
else:
print("Odd")
|
s697646914
|
p03657
|
u580404776
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a,b=map(int,input().split())
print('Possible' if a%3==0 or b%3==0 or a+b %3==0 else 'Impossible')
|
s874222973
|
Accepted
| 17 | 2,940 | 100 |
a,b=map(int,input().split())
print('Possible' if a%3==0 or b%3==0 or (a+b )%3==0 else 'Impossible')
|
s616340474
|
p02255
|
u026681847
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,648 | 249 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def insertionSort(At, Nt):
for i in range(Nt):
v = At[i]
j = i - 1
while j >= 0 and At[j] > v:
A[j + 1] = A[j]
j = j - 1
A[j + 1] = v
print(At)
return At
N = int(input())
A = list(map(int, input().split()))
A = insertionSort(A, N)
|
s117792021
|
Accepted
| 20 | 7,736 | 328 |
def insertionSort(At, Nt):
for i in range(Nt):
v = At[i]
j = i - 1
while j >= 0 and At[j] > v:
A[j + 1] = A[j]
j = j - 1
A[j + 1] = v
print(" ".join(map(str,At)))
return At
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split()))
A = insertionSort(A, N)
#print(" ".join(map(str,A)))
|
s046989766
|
p03644
|
u018679195
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 55 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
a = int(input())
i = 1
while(i<=a):
i *= 2
print(i/2)
|
s167867209
|
Accepted
| 17 | 2,940 | 86 |
n = int(input())
breakNum = 1
while breakNum*2 <= n:
breakNum *= 2
print(breakNum)
|
s874214679
|
p02608
|
u081075058
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 9,228 | 499 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
N = int(input())
x,y,z = 1,1,1
def is_true(x,y,z,i):
if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
return True
return False
loop = int(N ** (1/2))
for i in range(N):
count = 0
if i < 6:
print(count)
continue
for a in range(loop):
for b in range(loop):
for c in range(loop):
X = x+a
Y = y+b
Z = z+c
if is_true(X,Y,Z,i):
count += 1
print(count)
|
s215112152
|
Accepted
| 793 | 9,216 | 280 |
N = int(input())
ans = [0 for _ in range(10050)]
for x in range(1,100):
for y in range(1,100):
for z in range(1,100):
a = x**2 + y**2 + z**2 + x*y + y*z + z*x
if a < 10050:
ans[a] += 1
for i in range(1,N+1):
print(ans[i])
|
s462112285
|
p02612
|
u601271366
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,132 | 31 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
i = int(input())
print(i%1000)
|
s126139196
|
Accepted
| 29 | 9,140 | 79 |
i = int(input())
if i%1000 == 0:
print(0)
else:
print(1000 - (i%1000))
|
s497205273
|
p02396
|
u639135641
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 144 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
#Repetitive Processing - Print Test Cases
x=list(map(int,input().split()))
for i in range(len(x)-1):
print("Case " +str(i)+": "+str(x[i]))
|
s356689322
|
Accepted
| 160 | 5,596 | 156 |
### Repetitive Processing - Print Test Cases
i = 0
while True:
x = int(input());
i += 1
if x == 0: break
print("Case {}: {}".format(i, x))
|
s857230317
|
p03949
|
u754022296
| 2,000 | 262,144 |
Wrong Answer
| 694 | 150,292 | 911 |
We have a tree with N vertices. The vertices are numbered 1, 2, ..., N. The i-th (1 ≦ i ≦ N - 1) edge connects the two vertices A_i and B_i. Takahashi wrote integers into K of the vertices. Specifically, for each 1 ≦ j ≦ K, he wrote the integer P_j into vertex V_j. The remaining vertices are left empty. After that, he got tired and fell asleep. Then, Aoki appeared. He is trying to surprise Takahashi by writing integers into all empty vertices so that the following condition is satisfied: * Condition: For any two vertices directly connected by an edge, the integers written into these vertices differ by exactly 1. Determine if it is possible to write integers into all empty vertices so that the condition is satisfied. If the answer is positive, find one specific way to satisfy the condition.
|
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
T = [[] for _ in range(n+1)]
for _ in range(n-1):
a, b = map(int, input().split())
T[a].append(b)
T[b].append(a)
k = int(input())
VP = tuple(tuple(map(int, input().split())) for _ in range(k))
P = [-1]*(n+1)
A = [-1]*(n+1)
r = VP[0][0]
for v, p in VP:
P[v] = p
C = [None]*(n+1)
def dfs1(v, par=-1):
if P[v] == -1:
l = -float("inf")
r = float("inf")
else:
l = P[v]
r = P[v]
for nv in T[v]:
if nv == par:
continue
nl, nr = dfs1(nv, v)
l = max(l, nl-1)
r = min(r, nr+1)
if l > r:
print("No")
exit()
P[v] = (l, r)
return P[v]
dfs1(r)
def dfs2(v, ini, par=-1):
l, r = P[v]
if l <= ini-1 <= r:
A[v] = ini-1
else:
A[v] = ini+1
for nv in T[v]:
if nv == par:
continue
dfs2(nv, A[v], v)
dfs2(r, P[r][0])
print("Yes")
print(*A[1:], sep="\n")
|
s931885366
|
Accepted
| 669 | 198,532 | 1,009 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
n = int(input())
T = [[] for _ in range(n+1)]
for _ in range(n-1):
a, b = map(int, input().split())
T[a].append(b)
T[b].append(a)
k = int(input())
VP = tuple(tuple(map(int, input().split())) for _ in range(k))
P = [-1]*(n+1)
A = [-1]*(n+1)
r, c = VP[0]
for v, p in VP:
P[v] = p
def dfs1(v, par=-1, color=c%2):
if P[v] == -1:
l = -INF
r = INF
else:
l = P[v]
r = P[v]
for nv in T[v]:
if nv == par:
continue
nl, nr = dfs1(nv, v, color^1)
l = max(l, nl-1)
r = min(r, nr+1)
if l&1 ^ color:
l += 1
if r&1 ^ color:
r -= 1
if l > r:
print("No")
exit()
P[v] = (l, r)
return P[v]
dfs1(r)
def dfs2(v, ini, par=-1):
l, r = P[v]
if l == r:
A[v] = l
else:
if l <= ini-1 <= r:
A[v] = ini-1
else:
A[v] = ini+1
for nv in T[v]:
if nv == par:
continue
dfs2(nv, A[v], v)
dfs2(r, P[r][0])
print("Yes")
print(*A[1:], sep="\n")
|
s261551738
|
p03795
|
u052347048
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 67 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
from math import factorial
print(factorial(int(input()))%(10**9+7))
|
s135858479
|
Accepted
| 17 | 2,940 | 39 |
x=int(input());print(x*800-(x//15)*200)
|
s055569059
|
p04029
|
u653005308
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 31 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n=int(input())
print(n*(n+1)/2)
|
s043106531
|
Accepted
| 17 | 2,940 | 36 |
n=int(input())
print(int(n*(n+1)/2))
|
s174238956
|
p03545
|
u104282757
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 442 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
# C
ABCD = input()
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]
for i in range(8):
res = A
if i in [0, 2, 4, 6]:
res = res + '+' + B
else:
res = res + '-' + B
if i in [0, 1, 4, 5]:
res = res + '+' + C
else:
res = res + '-' + C
if i in [0, 1, 2, 3]:
res = res + '+' + D
else:
res = res + '-' + D
if eval(res) == 7:
print(res)
break
|
s343269019
|
Accepted
| 17 | 3,064 | 447 |
# C
ABCD = input()
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]
for i in range(8):
res = A
if i in [0, 2, 4, 6]:
res = res + '+' + B
else:
res = res + '-' + B
if i in [0, 1, 4, 5]:
res = res + '+' + C
else:
res = res + '-' + C
if i in [0, 1, 2, 3]:
res = res + '+' + D
else:
res = res + '-' + D
if eval(res) == 7:
print(res+'=7')
break
|
s483526877
|
p04011
|
u767545760
| 2,000 | 262,144 |
Wrong Answer
| 31 | 3,316 | 325 |
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
N = [int(input()) for i in range(4)]
if N[0] >= N[1]:
for i in range(N[0]):
print(str(i+1) + '泊目は' + str(N[2]) + '円です')
else:
for i in range(N[0]):
print(str(i+1) + '泊目は' + str(N[2]) + '円です')
for i in range(N[1] - N[0]):
print(str(N[0] + i+1) + '泊目は' + str(N[3]) + '円です')
|
s442864939
|
Accepted
| 18 | 2,940 | 128 |
N = [int(input()) for i in range(4)]
if N[0] <= N[1]:
print(N[2] * N[0])
else:
print(N[2] * N[1] + N[3] * (N[0] - N[1]))
|
s289330049
|
p02381
|
u216425054
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,692 | 215 |
You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑n _i_ =1(s _i_ \- m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance.
|
import math
while True:
n=int(input())
a=[int(x) for x in input().split()]
if a==[0]:
break
else:
m=sum(a)/n
print("{0:.5f}".format(math.sqrt(sum([(x-m)**2/n for x in a]))))
|
s585654110
|
Accepted
| 20 | 7,788 | 195 |
import math
while True:
n = int(input())
if n==0: break
s = list(map(int,input().split()))
m = sum(s)/float(n)
print("{0:.8f}".format(math.sqrt(sum([(x-m)**2 for x in s])/n)))
|
s798895027
|
p04043
|
u281610856
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 114 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
l = list(map(int, input().split()))
if l.count(5) == 2 and l.count(7) == 1:
print("Yes")
else:
print("No")
|
s234844140
|
Accepted
| 17 | 2,940 | 123 |
l = sorted(list(map(int, input().split())))
if l.count(5) == 2 and l.count(7) == 1:
print("YES")
else:
print("NO")
|
s708652250
|
p03502
|
u982594421
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,104 | 2,940 | 148 |
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
def f(n):
ans = 0
while n > 0:
ans += n % 10
n // 10
return ans
n = int(input())
if n % f(n) == 0:
print('Yes')
else:
print('No')
|
s784259605
|
Accepted
| 17 | 2,940 | 111 |
n = input()
ni = int(n)
f = 0
for ns in n:
f += int(ns)
if ni % f == 0:
print('Yes')
else:
print('No')
|
s429737660
|
p03732
|
u297574184
| 2,000 | 262,144 |
Wrong Answer
| 113 | 12,004 | 395 |
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items.
|
N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for i in range(N)]
w0 = items[0][0]
memo = [{} for i in range(N + 1)]
memo[0] = {0: 0}
for i, (wi, vi) in enumerate(items):
for w, v in memo[i].items():
if w + wi <= W:
memo[i + 1][w + wi] = v + vi
memo[i + 1][w] = max(memo[i + 1].get(w, 0), memo[i][w])
print(max(memo[N].values()))
|
s570806262
|
Accepted
| 1,110 | 3,064 | 620 |
import itertools
N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for i in range(N)]
minW = items[0][0]
arrVs = [[] for i in range(4)]
for w, v in items:
arrVs[w - minW].append(v)
acc = [[] for i in range(4)]
for i, arrV in enumerate(arrVs):
arrV.sort(reverse=True)
acc[i] = [0] + list(itertools.accumulate(arrV))
num = [range(len(acc[i])) for i in range(4)]
ans = 0
for n in itertools.product(num[0], num[1], num[2], num[3]):
w = sum([n[i] * (minW + i) for i in range(4)])
v = sum([acc[i][n[i]] for i in range(4)])
if w <= W:
ans = max(ans, v)
print(ans)
|
s164825250
|
p03067
|
u567744570
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 416 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
s = [int(i) for i in input().split(" ")]
count = 0
if s[0] < s[1]:
for i in range(s[0], s[1]):
print("1<2 : {}".format(i))
if i == s[2]:
print("Yes")
count = 1
break
else:
for i in range(s[1], s[0]):
print("2<1 : {}".format(i))
if i == s[2]:
print("Yes")
count = 1
break
if count == 0:
print("No")
|
s096807385
|
Accepted
| 17 | 3,060 | 348 |
s = [int(i) for i in input().split(" ")]
count = 0
if s[0] < s[1]:
for i in range(s[0], s[1]):
if i == s[2]:
print("Yes")
count = 1
break
else:
for i in range(s[1], s[0]):
if i == s[2]:
print("Yes")
count = 1
break
if count == 0:
print("No")
|
s706440698
|
p03623
|
u836737505
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 74 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b = map(int, input().split())
print("A" if abs(x-a)>abs(x-b) else "B")
|
s404288412
|
Accepted
| 17 | 2,940 | 74 |
x,a,b = map(int, input().split())
print("A" if abs(x-a)<abs(x-b) else "B")
|
s613569962
|
p03474
|
u007886915
| 2,000 | 262,144 |
Wrong Answer
| 40 | 5,332 | 6,171 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
# -*- coding: utf-8 -*-
import sys
import itertools
import fractions
import copy
import bisect
import math
#w=input()
from operator import itemgetter
from sys import stdin
from operator import mul
from functools import reduce
from collections import Counter
N=3
M=3
i=0
j=0
k=0
n=3
r=1
a=[0]*5
b=[]
c=[]
A,B=map(int, input().split())
#real=math.sqrt(N)
#r=int(input())
#print(real)
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"
s=input()
a=[i for i in s]
if a[A]!="-":
print("No")
sys.exit()
for i in range(A):
if a[i]!=1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9:
print("No")
sys.exit()
for i in range(B):
if a[i+A+1]!=1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9:
print("No")
sys.exit()
print("Yes")
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#print(type(brray[0][0]))
#print(brray)
"列数に関して自由度の高いint型の値を入力するタイプの行列"
'''
table = [[int(i) for i in input().split()] for m in range(m)]
print(type(N))
print(N)
print(type(M))
print(M)
print(type(table))
print(table)
'''
#s=input()
#print(a[0])
#print([a])
#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
##############################################################################################
##############################################################################################
#under this line explains example calculation
#nCr combination
'''
def cmb(n,r):
#When n < r , this function isn't valid
r= min(n-r,r)
#print(n,r)
if r == 0: return 1
over = reduce(mul, range(n, n-r, -1))
#flochart mul(n,n-1)=x
#next mul(x,n-2)........(n-r+1,n-r)
#mul read a,b and returns a*b
under = reduce(mul, range(1, r+1))
#print(over, under)
#reduce is applied mul(1,2)=2
#next mul(2,3)=6
#next mul(6,4)=4.........last(r!,r+1)=r+1!
return over // under
#// is integer divide
#calc example 5C2
#over=5*4*3
#under=3*2*1
a = cmb(n, r)
#print(a)
'''
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#A.insert(index, 5)
#print(index)
#print(A)
########################################################################
########################################################################
#print(b2)
#print(b3)
|
s592046176
|
Accepted
| 38 | 5,076 | 6,180 |
# -*- coding: utf-8 -*-
import sys
import itertools
import fractions
import copy
import bisect
import math
#w=input()
from operator import itemgetter
from sys import stdin
from operator import mul
from functools import reduce
from collections import Counter
N=3
M=3
i=0
j=0
k=0
n=3
r=1
a=[0]*5
b=["0","1", "2", "3", "4", "5", "6", "7", "8", "9"]
c=[]
A,B=map(int, input().split())
#real=math.sqrt(N)
#r=int(input())
#print(real)
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"
s=input()
a=[i for i in s]
if a[A]!="-":
print("No")
sys.exit()
for i in range(A):
#print(i)
if not a[i] in b:
print("No")
sys.exit()
for i in range(B):
#print(i+A)
if not a[i+A+1] in b:
print("No")
sys.exit()
print("Yes")
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#print(type(brray[0][0]))
#print(brray)
"列数に関して自由度の高いint型の値を入力するタイプの行列"
'''
table = [[int(i) for i in input().split()] for m in range(m)]
print(type(N))
print(N)
print(type(M))
print(M)
print(type(table))
print(table)
'''
#s=input()
#print(a[0])
#print([a])
#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
##############################################################################################
##############################################################################################
#under this line explains example calculation
#nCr combination
'''
def cmb(n,r):
#When n < r , this function isn't valid
r= min(n-r,r)
#print(n,r)
if r == 0: return 1
over = reduce(mul, range(n, n-r, -1))
#flochart mul(n,n-1)=x
#next mul(x,n-2)........(n-r+1,n-r)
#mul read a,b and returns a*b
under = reduce(mul, range(1, r+1))
#print(over, under)
#reduce is applied mul(1,2)=2
#next mul(2,3)=6
#next mul(6,4)=4.........last(r!,r+1)=r+1!
return over // under
#// is integer divide
#calc example 5C2
#over=5*4*3
#under=3*2*1
a = cmb(n, r)
#print(a)
'''
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#A.insert(index, 5)
#print(index)
#print(A)
########################################################################
########################################################################
#print(b2)
#print(b3)
|
s933553351
|
p03909
|
u984276646
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 210 |
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
|
H, W = map(int, input().split())
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S = [input() for _ in range(H)]
for i in range(H):
for j in range(W):
if S[i][j] == "snuke":
print("{}{}".format(i+1, alpha[j]))
|
s341531040
|
Accepted
| 17 | 3,060 | 235 |
H, W = map(int, input().split())
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S = [list(map(str, input().split())) for _ in range(H)]
for i in range(H):
for j in range(W):
if S[i][j] == "snuke":
print("{}{}".format(alpha[j], i+1))
|
s701403813
|
p03965
|
u845536647
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 63 |
AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn.
|
s=input()
g=s.count('g')
p=s.count('p')
a=g-p+(g+p)//2
print(a)
|
s606773363
|
Accepted
| 18 | 3,188 | 64 |
s=input()
g=s.count('g')
p=s.count('p')
a=(-p+(g+p)//2)
print(a)
|
s267124037
|
p03447
|
u668352391
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 127 |
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
x = int(input())
a = int(input())
b = int(input())
x = x -a
count = 0
while x - b < 0:
x = x - b
count += 1
print(x)
|
s683135074
|
Accepted
| 17 | 2,940 | 100 |
x = int(input())
a = int(input())
b = int(input())
x = x - a
while x - b >= 0:
x = x - b
print(x)
|
s325758005
|
p03679
|
u095021077
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,104 | 132 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
x, a, b=map(int, input().split())
if a<=b:
print('delicious')
else:
if b-a<x+1:
print('safe')
else:
print('dangerous')
|
s632110812
|
Accepted
| 22 | 9,012 | 133 |
x, a, b=map(int, input().split())
if a>=b:
print('delicious')
else:
if b-a<x+1:
print('safe')
else:
print('dangerous')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.