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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s529532623
|
p03471
|
u606523772
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 248 |
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.
|
N, Y = map(int, input().split())
tmp1 = Y // 10000
Y -= tmp1 * 10000
tmp2 = Y // 5000
Y -= tmp2 * 5000
tmp3 = Y // 1000
Y -= tmp3 * 1000
if Y==0:
ans1 = [str(tmp1), str(tmp2), str(tmp3)]
else:
ans1 = ["-1", "-1", "-1"]
print(" ".join(ans1))
|
s590857992
|
Accepted
| 1,501 | 3,060 | 267 |
N, Y = map(int, input().split())
ans1 = ["-1", "-1", "-1"]
for i in range(0, N+1):
for j in range(0, N+1):
if N-j>=0 and N-i-j >= 0:
if Y == 10000*i+5000*j+1000*(N-i-j):
ans1 = [str(i), str(j), str(N-i-j)]
print(" ".join(ans1))
|
s651296553
|
p03486
|
u391475811
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 123 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s=list(input().split())
t=list(input().split())
s.sort()
t.sort(reverse=True)
if s>=t:
print("No")
else:
print("Yes")
|
s885771242
|
Accepted
| 17 | 3,064 | 212 |
S=input().strip()
T=input().strip()
s=[]
t=[]
for i in range(len(S)):
s.append(str(S[i]))
for i in range(len(T)):
t.append(str(T[i]))
s.sort()
t.sort(reverse=True)
if s<t:
print("Yes")
else:
print("No")
|
s419672671
|
p03471
|
u827086165
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,064 | 449 |
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.
|
input_str = input().split()
N = int(input_str[0])
Y = int(input_str[1])
x_quo = Y//10000
for x in range(0,x_quo+1):
Y_x = Y - 10000*x
y_quo = Y_x // 5000
for y in range(0,y_quo+1):
Y_xy = Y_x - 5000*y
z_quo = Y_xy // 1000
for z in range(0,z_quo+1):
if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
break;
else:
continue
break
else:
continue
break
print(str(x) + " " + str(y) + " " + str(z))
|
s292695703
|
Accepted
| 735 | 3,064 | 458 |
input_str = input().split()
N = int(input_str[0])
Y = int(input_str[1])
x_quo = Y//10000
flag = False
for x in range(min([x_quo,N]),-1,-1):
Y_x = Y - 10000*x
N_x = N - x
y_quo = Y_x // 5000
for y in range(min([y_quo,N_x]),-1,-1):
z = N-x-y
if 10000*x + 5000*y + 1000*z == Y and x+y+z == N:
flag = True;
break;
else:
continue
break
if flag == True:
print(str(x) + " " + str(y) + " " + str(z))
else:
print("-1 -1 -1")
|
s410374865
|
p03339
|
u771365068
| 2,000 | 1,048,576 |
Wrong Answer
| 182 | 3,700 | 218 |
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
|
N = int(input())
S = input()
tmp = S[1:0].count('E')
minimum = tmp
for i in range(1, N):
if S[i-1] == 'W':
tmp += 1
if S[i] == 'E':
tmp -= 1
minimum = min(tmp, minimum)
print(minimum)
|
s498322636
|
Accepted
| 302 | 17,612 | 414 |
N = int(input())
S = input()
east = [0]*(N+1)
west = [0]*(N+1)
count = 0
for i, s in enumerate(S):
if s == 'E':
count+=1
east[i+1] = count
count = 0
for i, s in enumerate(S):
if s == 'W':
count+=1
west[i+1] = count
minimum = 10**6
for i in range(N):
tmp = (west[i]-west[0]) + (east[N]-east[i+1])
#print(tmp)
if tmp < minimum:
minimum = tmp
print(minimum)
|
s879656290
|
p03485
|
u479638406
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 60 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
x = (a + b)/2
print(x//1)
|
s682888150
|
Accepted
| 17 | 2,940 | 63 |
a, b = map(int, input().split())
x = (a + b + 1)//2
print(x)
|
s553585093
|
p02393
|
u108130680
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,580 | 86 |
Write a program which reads three integers, and prints them in ascending order.
|
a,b,c = map(int, input().split())
org_list =[a, b, c]
org_list.sort()
print(org_list)
|
s097481512
|
Accepted
| 20 | 5,588 | 290 |
a, b, c = map(int, input().split())
if a<b and a<c:
if b<c :
print(a, b, c)
else :
print(a, c, b)
elif b<a and b<c :
if a<c :
print(b, a, c)
else :
print(b, c, a)
else :
if a<b :
print(c, a, b)
else :
print(c, b, a)
|
s983183120
|
p03863
|
u924374652
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,316 | 172 |
There is a string s of length 3 or greater. No two neighboring characters in s are equal. Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first: * Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s. The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
|
s = input()
if s[0] == s[-1]:
if len(s) % 2 == 0:
print("First")
else:
print("Secon")
else:
if len(s) % 2 == 0:
print("Second")
else:
print("First")
|
s148413091
|
Accepted
| 17 | 3,316 | 178 |
s = input()
if s[0] == s[-1]:
if len(s) % 2 == 0:
print("First")
else:
print("Second")
else:
if len(s) % 2 == 0:
print("Second")
else:
print("First")
|
s318254958
|
p03657
|
u434630332
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,160 | 115 |
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())
if a + b == (a + b) % 3 == 0:
print("Possible")
else:
print("Impossible")
|
s044663956
|
Accepted
| 27 | 9,072 | 134 |
a, b = map(int, input().split())
if (a + b) % 3 == 0 or b % 3 == 0 or a % 3 == 0:
print("Possible")
else:
print("Impossible")
|
s087005888
|
p03471
|
u989074104
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,060 | 226 |
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.
|
import sys
N,Y = map(int,input().split())
for A in range(N+1):
for B in range(N-A+1):
for C in range(N-A-B+1):
if (10000*A+5000*B+1000*C==Y):
print(A,B,C)
sys.exit()
print(-1,-1,-1)
|
s015220325
|
Accepted
| 763 | 3,060 | 215 |
import sys
N,Y = map(int,input().split())
for A in range(N+1)[::-1]:
for B in range(N-A+1)[::-1]:
C=N-A-B
if (10000*A+5000*B+1000*C==Y):
print(A,B,C)
sys.exit()
print(-1,-1,-1)
|
s527780384
|
p03469
|
u074220993
| 2,000 | 262,144 |
Wrong Answer
| 26 | 8,796 | 48 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
S = input()
ans = S[:4] + '8' + S[5:]
print(ans)
|
s981341372
|
Accepted
| 26 | 8,948 | 31 |
s = input()
print('2018'+s[4:])
|
s169913760
|
p03564
|
u988832865
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 114 |
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
N = int(input())
K = int(input())
x = 1
for i in range(N):
if 2 * x < K:
x *= 2
else:
x += K
print(x)
|
s120534304
|
Accepted
| 18 | 2,940 | 119 |
N = int(input())
K = int(input())
x = 1
for i in range(N):
if 2 * x < x + K:
x *= 2
else:
x += K
print(x)
|
s066500946
|
p03636
|
u246572032
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 43 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
print(s[0],int(len(s))-2,s[-1])
|
s089932963
|
Accepted
| 17 | 2,940 | 66 |
s = input()
print(s[0],end='')
print(len(s)-2,end='')
print(s[-1])
|
s716069664
|
p03371
|
u767438459
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,184 | 221 |
"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())
if 2*c > a+b:
if 2*c < min(a,b):
print(c*max(x,y))
else:
if x>=y:
print(2*c*y+a*x)
else:
print(2*c*x+b*y)
else:
print(a*x+b*y)
|
s369795042
|
Accepted
| 28 | 9,192 | 140 |
a,b,c,x,y=map(int,input().split())
ans1=2*c*max(x,y)
ans2=2*c*min(x,y)+a*(x-min(x,y))+b*(y-min(x,y))
ans3=a*x+b*y
print(min(ans1,ans2,ans3))
|
s918066510
|
p02647
|
u680851063
| 2,000 | 1,048,576 |
Wrong Answer
| 2,207 | 51,148 | 536 |
We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row: * For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i. Find the intensity of each bulb after the K operations.
|
n, k = map(int,input().split())
l = list(map(int,input().split()))
dp = [[0] * 2 for i in range(n)]
ans = l[:]
for j in range(n):
dp[j][0] = (j+1 - ans[j] - 0.5)
dp[j][1] = (j+1 + ans[j] + 0.5)
for i in range(k):
ans = [0] * n
for x in range(n):
for y in range(n):
if dp[y][0] <= x+1 <= dp[y][1]:
ans[x] += 1
for j in range(n):
dp[j][0] = (j+1 - ans[j] - 0.5)
dp[j][1] = (j+1 + ans[j] + 0.5)
print(ans)
|
s277561162
|
Accepted
| 1,213 | 123,976 | 714 |
import numpy as np
from numba import njit
@njit
def imos(n, a):
l=np.zeros((n+1), dtype = np.int64)
for i, x in enumerate(a):
left = max(0, i - x)
right = min(n, i + x + 1)
l[left] += 1
l[right] -= 1
return np.cumsum(l)[:n]
n, k = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(k):
a = imos(n, a)
if a.min() == n:
break
print(*a)
|
s975560386
|
p03473
|
u050708958
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,316 | 24 |
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
print(int(input()) + 24)
|
s063485530
|
Accepted
| 17 | 2,940 | 22 |
print(48-int(input()))
|
s241162255
|
p03359
|
u031391755
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 69 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a,b = map(int,input().split())
if b<=a:
print(a+1)
else:
print(a)
|
s403764335
|
Accepted
| 17 | 2,940 | 80 |
a,b = map(int,input().split())
c = a - 1
if b<a :
print(c)
else:
print(a)
|
s251884952
|
p03680
|
u802234211
| 2,000 | 262,144 |
Wrong Answer
| 231 | 9,128 | 300 |
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
N = int(input())
button = list()
for i in range(N):
button.append(int(input()))
pre = 1
print(button)
i = 0
c = 1
rireki = [0]*N
while all:
if(button[i]==2):
print(c)
break
rireki[i] +=1
if(rireki[i]==2):
print(-1)
break
i = button[i]-1
c+=1
|
s409683589
|
Accepted
| 226 | 7,956 | 302 |
N = int(input())
button = list()
for i in range(N):
button.append(int(input()))
pre = 1
# print(button)
i = 0
c = 1
rireki = [0]*N
while all:
if(button[i]==2):
print(c)
break
rireki[i] +=1
if(rireki[i]==2):
print(-1)
break
i = button[i]-1
c+=1
|
s362434981
|
p03975
|
u842815814
| 1,000 | 262,144 |
Wrong Answer
| 21 | 3,060 | 203 |
Summer vacation ended at last and the second semester has begun. You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom. The barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the start of the B-th class. All the classes conducted when the barricade is blocking the entrance will be cancelled and you will not be able to attend them. Today you take N classes and class i is conducted in the t_i- th period. You take at most one class in each period. Find the number of classes you can attend.
|
import itertools
def getTi():
return int(input())
N,A,B = map(int, input().split())
t = [getTi() for i in range(N)]
t.sort()
td = list(itertools.dropwhile(lambda x:A<=x and x<B, t))
print(len(td))
|
s126084057
|
Accepted
| 17 | 2,940 | 103 |
N,A,B = map(int, input().split())
t = [(A <= int(input()) < B) for i in range(N)]
print(t.count(False))
|
s936208671
|
p03149
|
u173329233
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 93 |
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
n = list(map(int, input().split()))
n.sort()
print('Yes') if n==[1, 4, 7, 9] else print('No')
|
s657193275
|
Accepted
| 17 | 2,940 | 93 |
n = list(map(int, input().split()))
n.sort()
print('YES') if n==[1, 4, 7, 9] else print('NO')
|
s058344292
|
p03854
|
u955907183
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 315 |
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`.
|
c = input()
str1 = "dream"
str2 = "dreamer"
str3 = "erase"
str4 = "eraser"
tmpstr = ""
endflag = False
while(True):
tmpstr = c
c.replace(c, str1)
c.replace(c, str2)
c.replace(c, str3)
c.replace(c, str4)
if (c == tmpstr):
endflag = True
break
if (endflag):
print("NO")
else:
print("YES")
|
s649064649
|
Accepted
| 19 | 3,188 | 238 |
c = input().rstrip('\n')
str1 = "eraser"
str2 = "erase"
str3 = "dreamer"
str4 = "dream"
c = c.replace(str1, "")
c = c.replace(str2, "")
c = c.replace(str3, "")
c = c.replace(str4, "")
if (c == ""):
print("YES")
else:
print("NO")
|
s403416736
|
p00444
|
u376883550
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,572 | 152 |
太郎君はよくJOI雑貨店で買い物をする. JOI雑貨店には硬貨は500円,100円,50円,10円,5円,1円が十分な数だけあり,いつも最も枚数が少なくなるようなおつりの支払い方をする.太郎君がJOI雑貨店で買い物をしてレジで1000円札を1枚出した時,もらうおつりに含まれる硬貨の枚数を求めるプログラムを作成せよ. 例えば入力例1の場合は下の図に示すように,4を出力しなければならない.
|
COINS = [500, 100, 50, 10, 5, 1]
change = 1000 - int(input())
total = 0
for coin in COINS:
total += change // coin
change %= coin
print(total)
|
s339883816
|
Accepted
| 30 | 7,712 | 228 |
COINS = [500, 100, 50, 10, 5, 1]
change = 1000 - int(input())
while change != 1000:
total = 0
for coin in COINS:
total += change // coin
change %= coin
print(total)
change = 1000 - int(input())
|
s594148232
|
p02694
|
u978531093
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,156 | 139 |
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?
|
import math
x = int(input())
money = 100
i = 0
while True:
money = math.floor(money*1.01)
i += 1
if money > x:
break
print(i)
|
s384983064
|
Accepted
| 23 | 9,136 | 113 |
import math
X = int(input())
P = 100
step = 0
while P < X:
P += math.floor(P / 100)
step += 1
print(step)
|
s535499273
|
p03964
|
u566574814
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 164 |
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.
|
N = int(input())
t0, a0 = 1, 1
for _ in range(N):
t, a = map(int, input().split())
n = max((t0- 1)/ t+ 1, (a0-1)//a+1)
t0, a0 = n*t, n*a
print(t0 + a0)
|
s563806862
|
Accepted
| 20 | 3,060 | 165 |
N = int(input())
t0, a0 = 1, 1
for _ in range(N):
t, a = map(int, input().split())
n = max((t0- 1)// t+ 1, (a0-1)//a+1)
t0, a0 = n*t, n*a
print(t0 + a0)
|
s739718156
|
p03854
|
u661347997
| 2,000 | 262,144 |
Wrong Answer
| 201 | 3,316 | 265 |
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`.
|
words = ['dream', 'dreamer' ,'erase' ,'eraser']
t = ''
s = input()
s = s[::-1]
words = [word[::-1] for word in words]
start=0
for i in range(1, len(s)+1):
if s[start:i] in words:
t+=s[start:i]
start=i
if s==t:
print('True')
else:
print('False')
|
s812366372
|
Accepted
| 204 | 3,316 | 261 |
words = ['dream', 'dreamer' ,'erase' ,'eraser']
t = ''
s = input()
s = s[::-1]
words = [word[::-1] for word in words]
start=0
for i in range(1, len(s)+1):
if s[start:i] in words:
t+=s[start:i]
start=i
if s==t:
print('YES')
else:
print('NO')
|
s574535026
|
p03080
|
u231905444
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 116 |
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
n=int(input())
s=str(input())
s1=s.count('R')
s2=s.count('B')
if(s1>s2):
print('yes')
else:
print('no')
|
s240713031
|
Accepted
| 18 | 2,940 | 112 |
n=int(input())
s=str(input())
s1=s.count('R')
s2=s.count('B')
if(s1>s2):
print('Yes')
else:
print('No')
|
s603395040
|
p03575
|
u476958115
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 1,136 |
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M edges.
|
import sys
import itertools
N, M = [int(i) for i in sys.stdin.readline().split()]
edges = [[] for _ in range(N)]
for l in sys.stdin.readlines():
a, b = [int(i)-1 for i in l.strip().split()]
edges[a].append(b)
edges[b].append(a)
def flatten(l):
return list(itertools.chain.from_iterable(l))
def is_spanning_tree(edges):
new_edges = [[] for _ in range(N)]
for a, b in edges:
return 1
new_edges[a].append(b)
new_edges[b].append(a)
edges = new_edges
nodes = set([0])
next_node_candidates = set(flatten([edges[n] for n in nodes]))
while next_node_candidates:
nodes.add(list(next_node_candidates)[0])
next_node_candidates = set(flatten([edges[n] for n in nodes]))
next_node_candidates = nodes ^ next_node_candidates
return True if len(nodes) == N else False
cnt = 0
edges = flatten([[(i, j) for j in edges[i] if i>=j] for i in range(N)])
incomplete_graphs = [[edges[j] for j in range(len(edges)) if i != j] for i in range(len(edges))]
spanning_trees = [1 if not is_spanning_tree(graph) else 0 for graph in incomplete_graphs]
print(len(spanning_trees))
|
s780192368
|
Accepted
| 45 | 3,064 | 1,175 |
import sys
import itertools
N, M = [int(i) for i in sys.stdin.readline().split()]
edges = [[] for _ in range(N)]
for l in sys.stdin.readlines():
a, b = [int(i)-1 for i in l.strip().split()]
edges[a].append(b)
edges[b].append(a)
def flatten(l):
return list(itertools.chain.from_iterable(l))
def is_spanning_tree(edges):
# list of tuple to 2d-list
new_edges = [[] for _ in range(N)]
for a, b in edges:
new_edges[a].append(b)
new_edges[b].append(a)
edges = new_edges
nodes = set([0])
next_node_candidates = set(flatten([edges[n] for n in nodes]))
while next_node_candidates:
nodes.add(list(next_node_candidates)[0])
next_node_candidates = set(flatten([edges[n] for n in nodes]))
next_node_candidates = [x for x in next_node_candidates if x not in nodes]
return True if len(nodes) == N else False
cnt = 0
edges = flatten([[(i, j) for j in edges[i] if i>=j] for i in range(N)])
incomplete_graphs = [[edges[j] for j in range(len(edges)) if i != j] for i in range(len(edges))]
spanning_trees = [1 if not is_spanning_tree(graph) else 0 for graph in incomplete_graphs]
print(sum(spanning_trees))
|
s954947265
|
p03377
|
u657208344
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 85 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x=map(int,input().split())
if a <= x <= a+b:
print("Yes")
else:
print("No")
|
s579888348
|
Accepted
| 17 | 2,940 | 86 |
a, b, x=map(int,input().split())
if a <= x <= a+b:
print("YES")
else:
print("NO")
|
s345595175
|
p02612
|
u538516600
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,132 | 39 |
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.
|
N=int(input())
a = N%1000
print(a%1000)
|
s946481232
|
Accepted
| 28 | 9,100 | 46 |
N=int(input())
a = N%1000
print((1000-a)%1000)
|
s899824979
|
p02694
|
u416758623
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,100 | 117 |
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?
|
import math
x = int(input())
n = 100
i = 0
while n <= x:
n += n * 0.01
n = math.floor(n)
i += 1
print(i)
|
s168423944
|
Accepted
| 28 | 9,148 | 151 |
import math
x = int(input())
n = 100
i = 0
while n < x:
n = n * 101 // 100
i += 1
print(i)
|
s588585512
|
p02615
|
u677121387
| 2,000 | 1,048,576 |
Wrong Answer
| 157 | 31,424 | 238 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
ans = a[0]
idx = 1
flag = False
for i in range(n-1):
ans += a[idx]
if flag:
idx += 1
flag = False
else:
flag = True
print(ans)
|
s695715088
|
Accepted
| 158 | 31,356 | 239 |
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
ans = a[0]
idx = 1
flag = False
for i in range(n-2):
ans += a[idx]
if flag:
idx += 1
flag = False
else:
flag = True
print(ans)
|
s887205770
|
p03476
|
u022979415
| 2,000 | 262,144 |
Wrong Answer
| 1,172 | 4,980 | 815 |
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
|
def main():
numbers = [0] * (10 ** 5 + 1)
prime = [0] * (10 ** 5 + 1)
numbers[1] = 1
prime[1] = 1
for i in range(2, 10 ** 5 + 1):
if i % 2:
is_prime = True
j = 1
while j * j <= i and is_prime:
if (not i % j) and j > 1:
is_prime = False
j += 1
if is_prime:
prime[i] = 1
if is_prime and prime[(i + 1) // 2]:
numbers[i] = numbers[i - 1] + 1
else:
numbers[i] = numbers[i - 1]
else:
numbers[i] = numbers[i - 1]
query = int(input())
for _ in range(query):
left, right = map(int, input().split())
print(numbers[right] - numbers[left - 1])
if __name__ == '__main__':
main()
|
s311059296
|
Accepted
| 1,185 | 5,160 | 860 |
def is_prime(n):
result = True
i = 2
while i * i <= n:
if n % i == 0:
result = False
break
i += 1
if n == 1:
result = False
return result
def main():
q = int(input())
max_num = 10 ** 5
count_num = [0 for _ in range(max_num + 1)]
is_prime_num = [False for _ in range(max_num + 1)]
count_num[3] = 1
is_prime_num[3] = True
for i in range(4, max_num + 1):
count_num[i] = count_num[i - 1]
if i % 2:
if is_prime(i):
is_prime_num[i] = True
count_num[i] = count_num[i - 1]
if is_prime_num[(i + 1) // 2]:
count_num[i] += 1
for _ in range(q):
l, r = map(int, input().split())
print(count_num[r] - count_num[l - 1])
if __name__ == '__main__':
main()
|
s524553385
|
p03493
|
u847033024
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,136 | 207 |
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.
|
a = input()
if a[0] == a[1] == a[2] == 1:
print(3)
elif a[0] == a[1] == a[2] == 0:
print(0)
elif a[0] == a[1] == 1 or a[1] == a[2] == 1:
print(2)
elif a[0] == a[1] == 1 or a[1] == a[2] == 0:
print(1)
|
s918274258
|
Accepted
| 28 | 8,932 | 32 |
a = input()
print(a.count('1'))
|
s444346973
|
p03251
|
u296989351
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,128 | 204 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n, m, x, y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
xs.append(x)
ys.append(y)
if max(xs) < min(ys):
print("N0 War")
else:
print("War")
|
s956934186
|
Accepted
| 27 | 9,156 | 204 |
n, m, x, y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
xs.append(x)
ys.append(y)
if max(xs) < min(ys):
print("No War")
else:
print("War")
|
s894600381
|
p04012
|
u771538568
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 87 |
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
s=input()
a=len(s)
b=len(set(s))
if int(a/2)==b:
print("Yes")
else:
print("No")
|
s178446590
|
Accepted
| 18 | 2,940 | 153 |
s=input()
li=[i for i in s]
p="abcdefghijklmnopqrstuvwxyz"
for i in p:
if li.count(i)%2==1:
print("No")
exit()
else:
print("Yes")
|
s382441725
|
p03023
|
u859897687
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 38 |
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
n=int(input())
print(n*(180-360/n)//1)
|
s612450522
|
Accepted
| 17 | 2,940 | 31 |
n=int(input())
print(n*180-360)
|
s623784950
|
p03657
|
u449998745
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 116 |
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())
if a%3==0 or b%3==0 or (a+b)%3==0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
s686521649
|
Accepted
| 17 | 2,940 | 115 |
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
print("Possible")
else:
print("Impossible")
|
s641670726
|
p03456
|
u939552576
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 76 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
n = int(input().replace(' ',''))
print('Yes' if (n*(1/2))**2 == n else 'No')
|
s425307463
|
Accepted
| 18 | 3,060 | 82 |
n = int(input().replace(' ',''))
print('Yes' if (int(n**(1/2)))**2 == n else 'No')
|
s704826845
|
p02744
|
u933929042
| 2,000 | 1,048,576 |
Wrong Answer
| 112 | 18,024 | 223 |
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
|
n = int(input())
s = [[] for i in range(n+1)]
s[1].append('a')
ans_s = []
for num in range(1,n):
for st in s[num]:
for add in range(97, max(map(ord,st))+2):
s[num+1].append(st + chr(add))
print(s[n])
|
s016838049
|
Accepted
| 163 | 14,548 | 241 |
n = int(input())
s = [[] for i in range(n+1)]
s[1].append('a')
ans_s = []
for num in range(1,n):
for st in s[num]:
for add in range(97, max(map(ord,st))+2):
s[num+1].append(st + chr(add))
for sw in s[n]:
print(sw)
|
s480633480
|
p03386
|
u178432859
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 195 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,x = map(int, input().split())
l = list()
for i in range(x):
if a <= a+i <= b:
l.append(a+i)
if a <= b+i <= b:
l.append(b-i)
l = set(sorted(l))
for i in l:
print(i)
|
s524783282
|
Accepted
| 17 | 3,060 | 195 |
a,b,x = map(int, input().split())
l = list()
for i in range(x):
if a <= a+i <= b:
l.append(a+i)
if a <= b-i <= b:
l.append(b-i)
l = sorted(set(l))
for i in l:
print(i)
|
s577607588
|
p03385
|
u940047341
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 196 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
s = str(input())
if s[0] != s[1]:
if s[0] != s[2]:
if s[1] != s[2]:
print("yes")
else:
print("no")
else:
print("no")
else:
print("no")
|
s741000250
|
Accepted
| 18 | 2,940 | 191 |
s = input()
if s[0] != s[1]:
if s[0] != s[2]:
if s[1] != s[2]:
print("Yes")
else:
print("No")
else:
print("No")
else:
print("No")
|
s915097475
|
p03360
|
u703890795
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 87 |
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())
m = max(A,B,C)
print(A+B+C-m+m**K)
|
s297041989
|
Accepted
| 17 | 2,940 | 91 |
A, B, C = map(int, input().split())
K = int(input())
m = max(A,B,C)
print(A+B+C-m+m*(2**K))
|
s309446954
|
p02262
|
u370086573
| 6,000 | 131,072 |
Wrong Answer
| 20 | 7,748 | 629 |
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
def insertion_sort(r, n, g):
cnt = 0
for i in range(g, n):
v = r[i]
j = i - g
while v < r[j] and j >= 0:
r[j + g] = r[j]
j = j - g
cnt += 1
r[j + g] = v
def shell_sort(r, n):
global m
global G
h = 1
while True:
if h > n:
break
G.append(h)
h = h * 3 + 1
m = len(G)
G.reverse()
for i in range(m):
insertion_sort(r, n, G[i])
cnt = 0
G = []
m = 0
N = int(input())
R = [int(input()) for i in range(N)]
shell_sort(R, N)
print(m)
print(*G)
print(cnt)
for i in range(N):
print(R[i])
|
s102998631
|
Accepted
| 22,610 | 47,564 | 720 |
def insertionSort(n, A, g):
global cnt
for i in range(g, n):
temp = A[i]
j = i - g
while j >= 0 and A[j] > temp:
A[j + g] = A[j]
j -= g
cnt += 1
A[j + g] = temp
return A
def shellSort(A, n):
global m
global G
h = 1
while True:
if h > n:
break
G.append(h)
h = 3 * h + 1
G.reverse()
m =len(G)
for i in range(m):
insertionSort(n, A, G[i])
if __name__ == "__main__":
n = int(input())
A = [int(input()) for i in range(n)]
G = []
m = 0
cnt = 0
shellSort(A, n)
print(m)
print(*G)
print(cnt)
for i in range(n):
print(A[i])
|
s843890901
|
p03494
|
u546853743
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,148 | 176 |
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()))
cnt=0
for i in range(n):
if a[i]%2==0:
while a[i]%2 != 1:
a[i] /= 2
cnt += 1
print(cnt)
|
s399874099
|
Accepted
| 29 | 9,156 | 260 |
n=int(input())
a=list(map(int,input().split()))
b=[]
cnt=0
for i in range(n):
if a[i]%2==1:
print('0')
exit()
else:
while a[i]%2==0:
cnt += 1
a[i] /= 2
b.append(cnt)
cnt = 0
print(min(b))
|
s787676882
|
p03478
|
u844005364
| 2,000 | 262,144 |
Wrong Answer
| 32 | 2,940 | 157 |
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).
|
n, a, b = map(int, input().split())
cnt = 0
for i in range(1, n + 1):
str_n = str(n)
sum_n = sum(map(int, str_n))
cnt += a <= sum_n <= b
print(cnt)
|
s782811640
|
Accepted
| 31 | 2,940 | 168 |
n, a, b = map(int, input().split())
cnt = 0
for i in range(1, n + 1):
str_i = str(i)
sum_i = sum(map(int, str_i))
cnt += (a <= sum_i <= b) * i
print(cnt)
|
s190809275
|
p03719
|
u472883337
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 104 |
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=input().split()
a=int(a)
b=int(b)
c=int(c)
if(a<=c and b>=c):
print("YES")
else:
print("NO")
|
s980375923
|
Accepted
| 17 | 2,940 | 104 |
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if(a<=c and b>=c):
print("Yes")
else:
print("No")
|
s352418172
|
p03997
|
u102930666
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 68 |
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((a+b)*h/2)
|
s335855062
|
Accepted
| 17 | 2,940 | 73 |
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s237108331
|
p02612
|
u395866601
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 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.
|
n=int(input())
print(n%1000)
|
s587393677
|
Accepted
| 30 | 9,144 | 83 |
n=int(input())
ans=1000-n%1000
if ans==1000:
print(0)
else:
print(ans)
|
s810019522
|
p03502
|
u191423660
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 193 |
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.
|
N = input()
n = int(N)
ans = 0
for i in range(len(N)):
re = n % 10
n = int(n / 10)
ans += re
print(ans)
x = int(N)
if x%ans==0:
print('Yes')
else:
print('No')
|
s860087094
|
Accepted
| 17 | 2,940 | 178 |
N = input()
n = int(N)
ans = 0
for i in range(len(N)):
re = n % 10
n = int(n / 10)
ans += re
x = int(N)
if x%ans==0:
print('Yes')
else:
print('No')
|
s799501348
|
p03151
|
u708255304
| 2,000 | 1,048,576 |
Wrong Answer
| 100 | 19,660 | 347 |
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
|
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
magic_power = 0
for a, b in zip(A, B):
if a > b:
magic_power += (a-b)
ans = 0
for a, b in zip(A, B):
if a < b:
magic_power -= (b-a)
ans += 1
if magic_power < 0:
print(-1)
exit()
print(ans)
|
s000382666
|
Accepted
| 125 | 18,292 | 523 |
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(B) > sum(A):
print(-1)
exit()
remaining_power = []
for a, b in zip(A, B):
if a > b:
remaining_power.append(a-b)
remaining_power.sort(reverse=True)
need_power = 0
ans = 0
for a, b in zip(A, B):
if b > a:
ans += 1
need_power += (b-a)
cnt = 0
while need_power > 0:
need_power -= remaining_power[cnt]
cnt += 1
print(ans+cnt)
|
s919053388
|
p03479
|
u703890795
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 113 |
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence.
|
X, Y = map(int, input().split())
c = 1
while(True):
if X <= Y:
X *= 2
c += 1
else:
break
print(c)
|
s683256107
|
Accepted
| 17 | 2,940 | 115 |
X, Y = map(int, input().split())
c = 1
while(True):
if X*2 <= Y:
X *= 2
c += 1
else:
break
print(c)
|
s785915071
|
p03680
|
u931489673
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 133,392 | 261 |
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
N=int(input())
A=[]
I=[]
for n in range(N):
a=int(input())
A.append(a)
I.append(1)
def t(I):
while 2 not in I:
a=A[I[-1]-1]
if a in I:
return print(-1)
I.append(a)
print(I)
return print(len(I)-1)
t(I)
|
s485219876
|
Accepted
| 200 | 7,084 | 199 |
N=int(input())
A=[int(input()) for n in range(N)]
def t(N,A):
i=1
for n in range(1,N+1):
a=A[i-1]
if a==2:
return print(n)
i=a
return print(-1)
t(N,A)
|
s554251941
|
p03555
|
u382639013
| 2,000 | 262,144 |
Wrong Answer
| 24 | 9,104 | 104 |
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())
c1.reverse()
if c1 == c2:
print("Yes")
else:
print("No")
|
s291131125
|
Accepted
| 25 | 9,040 | 104 |
c1 = list(input())
c2 = list(input())
c1.reverse()
if c1 == c2:
print("YES")
else:
print("NO")
|
s334411459
|
p03846
|
u752513456
| 2,000 | 262,144 |
Wrong Answer
| 100 | 16,812 | 484 |
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
|
N = int(input())
A = input().split()
dic = dict()
for a in A:
a = int(a)
dic[a] = dic.get(a, 0) + 1
keys = dic.keys()
values = dic.values()
if N % 2 == 0:
if keys == [2*i+1 for i in range(N//2)] and values == [2 for i in range(N//2)]:
print(2**(N//2) % (10**9 + 7))
else:
print(0)
else:
if keys == [2*i for i in range(N//2)] and values == [1] + [2 for i in range(N//2 - 1)]:
print(2**(N//2) % (10**9 + 7))
else:
print(0)
|
s880149129
|
Accepted
| 110 | 14,008 | 403 |
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 == 0:
C = []
for c in [2*i+1 for i in range(N//2)]:
C += [c] * 2
if A == C:
print(2**(N//2) % (10**9 + 7))
else:
print(0)
else:
C = [0]
for c in [2*i for i in range(1, N//2 + 1)]:
C += [c] * 2
if A == C:
print(2**(N//2) % (10**9 + 7))
else:
print(0)
|
s328637853
|
p03944
|
u777028980
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 269 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
w,h,n=map(int,input().split())
x_a=0
x_b=w
y_a=0
y_b=h
for i in range(n):
x,y,z=map(int,input().split())
if(z==1):
x_a=max(x_a,x)
elif(z==2):
x_b=min(x_a,x)
elif(z==3):
y_a=max(y_a,y)
elif(z==4):
y_b=min(y_a,y)
print((x_b-x_a)*(y_b-y_a))
|
s803508218
|
Accepted
| 18 | 3,064 | 315 |
w,h,n=map(int,input().split())
x_a=0
x_b=w
y_a=0
y_b=h
for i in range(n):
x,y,z=map(int,input().split())
if(z==1):
x_a=max(x_a,x)
elif(z==2):
x_b=min(x_b,x)
elif(z==3):
y_a=max(y_a,y)
elif(z==4):
y_b=min(y_b,y)
if(x_b-x_a>0 and y_b-y_a>0):
print((x_b-x_a)*(y_b-y_a))
else:
print(0)
|
s796041398
|
p03228
|
u970809473
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 204 |
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
|
a,b,k = map(int, input().split())
for i in range(k):
if i % 2 == 0:
if a % 2 == 1:
a = (a - 1) // 2
b = b + a
else:
if b % 2 == 1:
b = (b - 1) // 2
a = a + b
print(a,b)
|
s237119542
|
Accepted
| 17 | 2,940 | 151 |
a,b,k = map(int, input().split())
for i in range(k):
if i % 2 == 0:
a = a // 2
b = b + a
else:
b = b // 2
a = a + b
print(a,b)
|
s408046235
|
p02744
|
u268554510
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 7,148 | 600 |
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
|
N = int(input())
import itertools
from collections import deque
ans = deque()
l = []
for i in range(N):
l.append(chr(97+i))
for x in itertools.product(l, repeat=N):
f = [0]*10
x = list(x)
judge = True
k = False
for w in x:
w = ord(w)-97
f[w]=1
if sum(f[:w])>=w:
continue
else:
k = True
if k:
continue
for j,y in enumerate(x[:i+1]):
if y in l[:j+1]:
continue
else:
judge=False
break
if judge:
ans.append(''.join(x))
ans = set(ans)
ans = sorted(list(ans))
print(ans)
|
s890329853
|
Accepted
| 206 | 13,940 | 483 |
N = int(input())
from collections import deque
import itertools
ans = deque()
l = []
r = deque()
for i in range(N):
l.append(chr(97+i))
r.append(l.copy())
p = [[[] for _ in range(N)] for _ in range(N)]
p[0][0].append('a')
for i in range(1,N):
for j in r[i]:
x = ord(j)-97
for n,k in enumerate(p[i-1][max(0,x-1):],max(0,x-1)):
for m in k:
p[i][max(n,x)].append(m+j)
p = p[-1]
p = list(itertools.chain.from_iterable(p))
p.sort()
for q in p:
print(q)
|
s561264959
|
p03475
|
u099918199
| 3,000 | 262,144 |
Wrong Answer
| 122 | 3,188 | 553 |
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.
|
n = int(input())
list_prob = []
for i in range(n-1):
list_prob.append(list(map(int, input().split())))
print(list_prob)
for i in range(n-1):
j = i
ans = 0
ans += list_prob[j][1]
ans += list_prob[j][0]
j += 1
while j < n-1:
if ans < list_prob[j][1]:
ans = list_prob[j][1]
else:
if ans % list_prob[j][2] != 0:
ans += (list_prob[j][2] - (ans % list_prob[j][2]))
else:
pass
ans += list_prob[j][0]
j += 1
print(ans)
print(0)
|
s180967671
|
Accepted
| 119 | 3,188 | 536 |
n = int(input())
list_prob = []
for i in range(n-1):
list_prob.append(list(map(int, input().split())))
for i in range(n-1):
j = i
ans = 0
ans += list_prob[j][1]
ans += list_prob[j][0]
j += 1
while j < n-1:
if ans < list_prob[j][1]:
ans = list_prob[j][1]
else:
if ans % list_prob[j][2] != 0:
ans += (list_prob[j][2] - (ans % list_prob[j][2]))
else:
pass
ans += list_prob[j][0]
j += 1
print(ans)
print(0)
|
s331682300
|
p03171
|
u844005364
| 2,000 | 1,048,576 |
Wrong Answer
| 2,111 | 117,512 | 424 |
Taro and Jiro will play the following game against each other. Initially, they are given a sequence a = (a_1, a_2, \ldots, a_N). Until a becomes empty, the two players perform the following operation alternately, starting from Taro: * Remove the element at the beginning or the end of a. The player earns x points, where x is the removed element. Let X and Y be Taro's and Jiro's total score at the end of the game, respectively. Taro tries to maximize X - Y, while Jiro tries to minimize X - Y. Assuming that the two players play optimally, find the resulting value of X - Y.
|
n = int(input())
arr = list(map(int, input().split()))
dp = [[0] * (n+1) for _ in range(n+1)]
for length in range(1, n + 1):
for i in range(n - length + 1):
j = i + length
if ((n - length) % 2 == 0):
dp[i][j] = max(dp[i+1][j] + arr[i], dp[i][j-1] + arr[j-1])
else:
dp[i][j] = min(dp[i+1][j] - arr[i], dp[i][j-1] - arr[j-1])
print(i,j,dp[i][j])
print(dp[0][n])
|
s678484661
|
Accepted
| 1,467 | 234,048 | 412 |
def kukan(n, a):
dp = [[0] * n for _ in range(n)]
for i in range(n):
dp[i][i] = a[i]
for i in range(n - 2, -1, -1):
g0 = dp[i]
g1 = dp[i + 1]
for j in range(i + 1, n):
L = a[i] - g1[j]
R = a[j] - g0[j - 1]
dp[i][j] = L if L > R else R
return dp[0][n - 1]
n = int(input())
a = list(map(int, input().split()))
print(kukan(n, a))
|
s669695203
|
p02603
|
u163529815
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,212 | 508 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
import sys
def input():
return sys.stdin.readline()[:-1]
def main():
N = int(input())
A = list(map(int,input().split()))
zougen = [-1 if A[i] > A[i + 1] else 1 for i in range(N - 1)]
print(zougen)
money = 1000
kabu = 0
for i in range(N-1):
if zougen[i] == 1:
kabu += money // A[i]
money = money % A[i]
else:
money += kabu * A[i]
kabu = 0
print(A[-1] * kabu + money)
if __name__ == "__main__":
main()
|
s191676488
|
Accepted
| 32 | 8,936 | 490 |
import sys
def input():
return sys.stdin.readline()[:-1]
def main():
N = int(input())
A = list(map(int,input().split()))
zougen = [-1 if A[i] > A[i + 1] else 1 for i in range(N - 1)]
money = 1000
kabu = 0
for i in range(N-1):
if zougen[i] == 1:
kabu += money // A[i]
money = money % A[i]
else:
money += kabu * A[i]
kabu = 0
print(A[-1] * kabu + money)
if __name__ == "__main__":
main()
|
s227231141
|
p02401
|
u242221792
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,564 | 101 |
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
|
for i in range(10000):
try:
a = eval(input())
print(a)
except:
break
|
s491509404
|
Accepted
| 20 | 5,556 | 106 |
for i in range(10000):
try:
a = eval(input())
print(int(a))
except:
break
|
s664420574
|
p02615
|
u347640436
| 2,000 | 1,048,576 |
Wrong Answer
| 155 | 31,436 | 149 |
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
result = 0
for i in range(N):
result += A[(i + 1) // 2]
print(result)
|
s367559165
|
Accepted
| 147 | 31,436 | 153 |
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
result = 0
for i in range(N - 1):
result += A[(i + 1) // 2]
print(result)
|
s025246519
|
p03214
|
u557494880
| 2,525 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 204 |
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail.
|
N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N
ans = 0
sa = 10**9
for i in range(N):
t = i+1
x = max(A[i]-ave,ave-A[i])
if x < sa:
sa = x
ans = t
print(ans)
|
s050248646
|
Accepted
| 17 | 3,060 | 192 |
N = int(input())
A = list(map(int,input().split()))
ave = sum(A)/N
ans = 0
sa = 10**9
for i in range(N):
x = max(A[i]-ave,ave-A[i])
if x < sa:
sa = x
ans = i
print(ans)
|
s621382556
|
p03473
|
u429029348
| 2,000 | 262,144 |
Wrong Answer
| 16 | 2,940 | 23 |
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
m=int(input())
ans=48-m
|
s342440902
|
Accepted
| 17 | 2,940 | 34 |
m=int(input())
ans=48-m
print(ans)
|
s678332092
|
p03369
|
u706828591
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 132 |
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.
|
#a, b, c, d = map(int,input().split())
#ls = list(map(int,input().split()))
#r = int(input())
s = input()
print(700 * s.count("o"))
|
s724460636
|
Accepted
| 17 | 2,940 | 138 |
#a, b, c, d = map(int,input().split())
#ls = list(map(int,input().split()))
#r = int(input())
s = input()
print(700 + s.count("o") * 100)
|
s895641613
|
p02390
|
u737543412
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,584 | 313 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
def watch(s):
hh = s / (60 * 60)
mm_s = s % (60 * 60)
mm = mm_s / 60
ss = mm_s % 60
print(str(hh) + ":" + str(mm) + ":" + str(ss))
s = int(input())
watch(s)
|
s680763020
|
Accepted
| 20 | 7,724 | 355 |
def watch(s):
hh = s // (60 * 60) # ??????????????????
mm_s = s % (60 * 60)
mm = mm_s // 60 # ???????????????
ss = mm_s % 60
print(str(hh) + ":" + str(mm) + ":" + str(ss))
s = int(input())
watch(s)
|
s986482567
|
p03556
|
u107039373
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 51 |
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.
|
import math
print(int(math.sqrt(int(input()))//1))
|
s946817578
|
Accepted
| 17 | 2,940 | 32 |
print(int(int(input())**0.5)**2)
|
s029587428
|
p03731
|
u634079249
| 2,000 | 262,144 |
Wrong Answer
| 116 | 29,112 | 1,128 |
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?
|
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
# import fractions
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)
MOD = 10 ** 9 + 7
MAX = float('inf')
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N, K = il()
T = il()
ret = 0
for n in range(N - 1):
ret += min(T[n + 1] - T[n], K)
print(ret)
if __name__ == '__main__':
main()
|
s861761984
|
Accepted
| 124 | 29,212 | 1,140 |
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
# import fractions
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)
MOD = 10 ** 9 + 7
MAX = float('inf')
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N, T = il()
time = il()
ret = T
for n in range(N-1):
ret += min(abs(time[n] - time[n + 1]), T)
print(ret)
if __name__ == '__main__':
main()
|
s521092391
|
p03836
|
u054514819
| 2,000 | 262,144 |
Wrong Answer
| 2,209 | 166,584 | 1,335 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)
from collections import defaultdict, deque
Dirc = ('U', 'D', 'R', 'L')
Dirc2 = ('D', 'U', 'L', 'R')
dircn = ((1, 0), (-1, 0), (0, 1), (0, -1))
blocked = defaultdict(int)
sx, sy, tx, ty = mapint()
ans = []
for i in range(4):
queue = deque([(sx, sy, [])])
checked = defaultdict(int)
dirc = Dirc if i%2==0 else Dirc2
while queue:
x, y, lis = queue.popleft()
lis = lis[:]
flg = 0
for d, (dy, dx) in zip(dirc, dircn):
nx, ny = x+dx, y+dy
if checked[(nx, ny)] or blocked[(nx, ny)]:
continue
if nx==sx and ny==sy:
continue
if nx==tx and ny==ty:
flg = 1
lis.append(d)
break
lis.append(d)
queue.append((nx, ny, lis))
lis.pop()
checked[(nx, ny)] = 1
if flg:
x, y = sx, sy
for s in lis[:-1]:
dy, dx = dircn[dirc.index(s)]
x += dx
y += dy
blocked[(x, y)] = 1
if i%2==0:
lis = list(reversed(lis))
ans.extend(lis)
break
print(''.join(ans))
|
s726814722
|
Accepted
| 28 | 9,020 | 338 |
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)
sx, sy, tx, ty = mapint()
ans = ''
ans += 'U'*(ty-sy) + 'R'*(tx-sx)
ans += 'D'*(ty-sy) + 'L'*(tx-sx)
ans += 'L'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'
ans += 'R'+'D'*(ty-sy+1) + 'L'*(tx-sx+1)+'U'
print(ans)
|
s468564364
|
p03386
|
u113971909
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 125 |
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
A,B,K = map(int,input().split())
for _ in range(A,min(A+K,max(B-K,A))):
print(_)
for _ in range(max(B-K,A),B+1):
print(_)
|
s135462139
|
Accepted
| 17 | 3,060 | 174 |
A,B,K = map(int,input().split())
if (2*K)<(B-A+2):
for i in range(A,A+K):
print(i)
for i in range(B-K+1,B+1):
print(i)
else:
for i in range(A,B+1):
print(i)
|
s759646614
|
p04043
|
u143278390
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 226 |
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.
|
s=[int(i) for i in input().split()]
five_count=0
seven_count=0
for i in s:
if(s==5):
five_count+=1
elif(s==7):
seven_count+=1
if(five_count==2 and seven_count==1):
print('YES')
else:
print('NO')
|
s406696371
|
Accepted
| 17 | 3,060 | 226 |
s=[int(i) for i in input().split()]
five_count=0
seven_count=0
for i in s:
if(i==5):
five_count+=1
elif(i==7):
seven_count+=1
if(five_count==2 and seven_count==1):
print('YES')
else:
print('NO')
|
s655600303
|
p03478
|
u844172143
| 2,000 | 262,144 |
Wrong Answer
| 36 | 3,064 | 236 |
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).
|
import math
N, A, B = map(int, input().split())
print(N)
print(A)
print(B)
total = 0
for n in range(N+1):
numbers = list(str(n))
sum = 0
for part in numbers:
sum += int(part)
if A <= sum & sum <= B:
total += n
print(total)
|
s949141597
|
Accepted
| 37 | 3,060 | 210 |
import math
N, A, B = map(int, input().split())
total = 0
for n in range(N+1):
numbers = list(str(n))
sum = 0
for part in numbers:
sum += int(part)
if A <= sum & sum <= B:
total += n
print(total)
|
s898847431
|
p02399
|
u904226154
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,604 | 105 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a, b = map(int, input().split())
print(str(a / b) + " " + str(a % b) + " " + str("{0:.5f}".format(a/b)))
|
s784645395
|
Accepted
| 20 | 5,604 | 106 |
a, b = map(int, input().split())
print(str(a // b) + " " + str(a % b) + " " + str("{0:.5f}".format(a/b)))
|
s962065176
|
p03623
|
u305732215
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 105 |
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())
ax = abs(a-x)
bx = abs(b-x)
if ax > bx:
print(bx)
else:
print(ax)
|
s665421990
|
Accepted
| 17 | 2,940 | 107 |
x, a, b = map(int, input().split())
ax = abs(a-x)
bx = abs(b-x)
if ax > bx:
print('B')
else:
print('A')
|
s716945162
|
p02694
|
u205762924
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,092 | 138 |
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())
year = 0
total = 100
while total < X:
total = round(total + 0.01 * total)
year += 1
print(total)
print(year)
|
s622468296
|
Accepted
| 21 | 9,012 | 124 |
X = int(input())
year = 0
total = 100
while total < X:
total = total + int(0.01 * total)
year += 1
print(year)
|
s440163062
|
p03486
|
u476048753
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 155 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
x = input()
y = input()
xnew = sorted(x)
xnew = ''.join(xnew)
ynew = sorted(y)
ynew = ''.join(ynew)
if xnew < ynew:
print("Yes")
else:
print("No")
|
s687742890
|
Accepted
| 19 | 3,060 | 176 |
x = input()
y = input()
xnew = sorted(x)
xnew = ''.join(xnew)
ynew = sorted(y)
ynew.reverse()
ynew = ''.join(ynew)
if xnew < ynew:
print("Yes")
else:
print("No")
|
s692212032
|
p03433
|
u493491792
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 86 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = int(input())
a = int(input())
if n%500<=a:
print("yes")
else:
print("no")
|
s944266468
|
Accepted
| 17 | 2,940 | 86 |
n = int(input())
a = int(input())
if n%500<=a:
print("Yes")
else:
print("No")
|
s538706625
|
p02258
|
u354053070
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,656 | 139 |
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
|
N = int(input())
M, m = 1, 10 ** 9
for _ in range(N):
n = int(input())
M = n if M < n else M
m = n if m > n else m
print(M - m)
|
s588697693
|
Accepted
| 420 | 7,732 | 159 |
N = int(input())
P, m = - 10 ** 9, int(input())
for _ in range(1, N):
n = int(input())
P = n - m if n - m > P else P
m = n if m > n else m
print(P)
|
s093077636
|
p03847
|
u631277801
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 1,061 |
You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7.
|
import sys
stdin = sys.stdin
def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())
MOD = 10**9+7
n = 1000000000000000000
n_bit = len(bin(n)[2:])
dp = [[0]*4 for _ in range(n_bit+1)]
dp[0][0] = 1
for bit in range(n_bit):
digit = int(bin(n)[2+bit:2+bit+1])
if digit:
dp[bit+1][0] = (dp[bit][0]) % MOD
dp[bit+1][1] = (dp[bit][0] + dp[bit][1]) % MOD
dp[bit+1][2] = (dp[bit][1]) % MOD
dp[bit+1][3] = (dp[bit][1] + 3*dp[bit][2] + 3*dp[bit][3]) % MOD
else:
dp[bit+1][0] = (dp[bit][0] + dp[bit][1]) % MOD
dp[bit+1][1] = (dp[bit][1]) % MOD
dp[bit+1][2] = (dp[bit][1] + dp[bit][2]) % MOD
dp[bit+1][3] = (2*dp[bit][2] + 3*dp[bit][3]) % MOD
print(sum(dp[n_bit]) % MOD)
|
s927557110
|
Accepted
| 18 | 3,188 | 1,046 |
import sys
stdin = sys.stdin
def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())
MOD = 10**9+7
n = ni()
n_bit = len(bin(n)[2:])
dp = [[0]*4 for _ in range(n_bit+1)]
dp[0][0] = 1
for bit in range(n_bit):
digit = int(bin(n)[2+bit:2+bit+1])
if digit:
dp[bit+1][0] = (dp[bit][0]) % MOD
dp[bit+1][1] = (dp[bit][0] + dp[bit][1]) % MOD
dp[bit+1][2] = (dp[bit][1]) % MOD
dp[bit+1][3] = (dp[bit][1] + 3*dp[bit][2] + 3*dp[bit][3]) % MOD
else:
dp[bit+1][0] = (dp[bit][0] + dp[bit][1]) % MOD
dp[bit+1][1] = (dp[bit][1]) % MOD
dp[bit+1][2] = (dp[bit][1] + dp[bit][2]) % MOD
dp[bit+1][3] = (2*dp[bit][2] + 3*dp[bit][3]) % MOD
print(sum(dp[n_bit]) % MOD)
|
s019600367
|
p02619
|
u177411511
| 2,000 | 1,048,576 |
Wrong Answer
| 181 | 26,964 | 814 |
Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
import numpy as np
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
D = ni()
c = na()
s = [na() for _ in range(D)]
out = [ni() for _ in range(D)]
sat = 0
last = [0] * 26
for d in range(D):
assert(1 <= out[d] and out[d] <= 26)
idx = -1
li = []
for k in range(26):
last_t = last
sat_t = sat
j = k
last_t[j] = d + 1
for i in range(26):
sat_t -= (d + 1 - last_t[i]) * c[i]
sat_t += s[d][j]
li.append(sat_t)
sat = max(li)
last[np.argmax(li)] = d + 1
print(sat)
|
s974567455
|
Accepted
| 45 | 11,012 | 611 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
D = ni()
c = na()
s = [na() for _ in range(D)]
out = [ni() for _ in range(D)]
sat = 0
last = [0] * 26
for d in range(D):
assert(1 <= out[d] and out[d] <= 26)
j = out[d] - 1
last[j] = d + 1
for i in range(26):
sat -= (d + 1 - last[i]) * c[i]
sat += s[d][j]
print(sat)
|
s210510634
|
p03860
|
u012662940
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 40 |
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.
|
s = input()
print('A' + str(s[0]) + 'C')
|
s106553354
|
Accepted
| 17 | 2,940 | 29 |
print("A" + input()[8] + "C")
|
s978484367
|
p03737
|
u864667985
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 43 |
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
a,b,c=input().split();print(a[0]+b[0]+c[0])
|
s051707511
|
Accepted
| 18 | 2,940 | 86 |
l = input().split()
ans = ""
for i in range(3):
ans += l[i][0].upper()
print(ans)
|
s590865182
|
p04044
|
u829094246
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 79 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
N,L=map(int, input().split())
"".join(sorted([input()[:L] for i in range(N)]))
|
s330419608
|
Accepted
| 17 | 3,060 | 86 |
N,L=map(int, input().split())
print("".join(sorted([input()[:L] for i in range(N)])))
|
s059960057
|
p03485
|
u506587641
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 44 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
print(a//b)
|
s623917609
|
Accepted
| 17 | 2,940 | 83 |
a, b = map(int, input().split())
print((a+b)//2 if (a+b)%2 == 0 else (a+b)//2 + 1)
|
s048769227
|
p03545
|
u107915058
| 2,000 | 262,144 |
Wrong Answer
| 32 | 9,148 | 288 |
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.
|
A,B,C,D = map(int, input())
ans = list(str(A))
for b in [-B,B]:
for c in [-C,C]:
for d in [-D,D]:
if sum([A,b,c,d]) == 7:
ans += ["+" + str(x) if x>=0 else str(x) for x in [b,c,d]]
break
for i in ans:
print(i, end = "")
print("=7")
|
s602333309
|
Accepted
| 28 | 9,116 | 259 |
abcd = input()
n = len(abcd)
for i in range(1<<n-1):
ans = abcd[0]
for j in range(n-1):
if i>>j&1:
ans += "-" + abcd[j+1]
else:
ans += "+" + abcd[j+1]
if eval(ans) == 7:
print(ans+"=7")
break
|
s716918331
|
p03712
|
u004025573
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 242 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
n,m=map(int,input().split())
S=[]
for i in range(n):
tmp=input()
S.append(tmp)
s=[]
for i in range(m+2):
s.append("#")
print(''.join(s))
for i in range(n):
tmp=["#", S[0], "#"]
print(''.join(tmp))
print(''.join(s))
|
s976072301
|
Accepted
| 17 | 3,060 | 242 |
n,m=map(int,input().split())
S=[]
for i in range(n):
tmp=input()
S.append(tmp)
s=[]
for i in range(m+2):
s.append("#")
print(''.join(s))
for i in range(n):
tmp=["#", S[i], "#"]
print(''.join(tmp))
print(''.join(s))
|
s565059621
|
p03854
|
u865413330
| 2,000 | 262,144 |
Wrong Answer
| 33 | 4,852 | 675 |
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()
def calc(s):
if s == "":
return print("Yes")
if s.find("dreameraser") != -1:
s = s.replace("dreameraser", "")
return calc(s)
elif s.find("dreamerase") != -1:
s = s.replace("dreamerase", "")
return calc(s)
elif s.find("dreamer") != -1:
s = s.replace("dreamer", "")
return calc(s)
elif s.find("dream") != -1:
s = s.replace("dream", "")
return calc(s)
elif s.find("eraser") != -1:
s = s.replace("eraser", "")
return calc(s)
elif s.find("erase") != -1:
s = s.replace("erase", "")
return calc(s)
return print("No")
calc(s)
|
s888659984
|
Accepted
| 31 | 4,852 | 675 |
s = input()
def calc(s):
if s == "":
return print("YES")
if s.find("dreameraser") != -1:
s = s.replace("dreameraser", "")
return calc(s)
elif s.find("dreamerase") != -1:
s = s.replace("dreamerase", "")
return calc(s)
elif s.find("dreamer") != -1:
s = s.replace("dreamer", "")
return calc(s)
elif s.find("dream") != -1:
s = s.replace("dream", "")
return calc(s)
elif s.find("eraser") != -1:
s = s.replace("eraser", "")
return calc(s)
elif s.find("erase") != -1:
s = s.replace("erase", "")
return calc(s)
return print("NO")
calc(s)
|
s631457048
|
p03434
|
u757919796
| 2,000 | 262,144 |
Wrong Answer
| 24 | 3,060 | 170 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n = int(input())
l = list(map(int, input().split(' ')))
l.sort()
l.reverse()
result = 0
for e in enumerate(l):
result += e[1] if e[0] % 2 else -e[1]
print(result)
|
s014077071
|
Accepted
| 17 | 3,060 | 175 |
n = int(input())
l = list(map(int, input().split(' ')))
l.sort()
l.reverse()
result = 0
for e in enumerate(l):
result += e[1] if e[0] % 2 == 0 else -e[1]
print(result)
|
s136504734
|
p03795
|
u766407523
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 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-(N/15)*200)
|
s299199251
|
Accepted
| 17 | 2,940 | 41 |
N = int(input())
print(N*800-(N//15)*200)
|
s345306733
|
p02613
|
u655663334
| 2,000 | 1,048,576 |
Wrong Answer
| 145 | 16,432 | 229 |
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())
Ss = [input() for _ in range(N)]
import collections
c = collections.Counter(Ss)
print(c)
print("AC x " + str(c["AC"]))
print("WA x " + str(c["WA"]))
print("TLE x " + str(c["TLE"]))
print("RE x " + str(c["RE"]))
|
s052666341
|
Accepted
| 149 | 16,464 | 221 |
N = int(input())
Ss = [input() for _ in range(N)]
import collections
c = collections.Counter(Ss)
print("AC x " + str(c["AC"]))
print("WA x " + str(c["WA"]))
print("TLE x " + str(c["TLE"]))
print("RE x " + str(c["RE"]))
|
s692314246
|
p03698
|
u262597910
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 138 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
s = input()
end = []
for i in s:
if (end.count(i)==0):
end.append(i)
else:
print("no")
exit()
print("Yes")
|
s213126880
|
Accepted
| 17 | 2,940 | 138 |
s = input()
end = []
for i in s:
if (end.count(i)==0):
end.append(i)
else:
print("no")
exit()
print("yes")
|
s346675594
|
p03377
|
u702018889
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 101 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a=input()
a=[int(x) for x in a.split()]
b=a[0]+a[1]
c=a[2]
print("Yes" if a[0]<=c and c<=b else "No")
|
s751887853
|
Accepted
| 17 | 2,940 | 85 |
a, b, x = [int(i) for i in input().split()]
print("YES" if a <= x <= a + b else "NO")
|
s120627942
|
p02273
|
u665238221
| 2,000 | 131,072 |
Wrong Answer
| 20 | 5,644 | 657 |
Write a program which reads an integer _n_ and draws a Koch curve based on recursive calles of depth _n_. The Koch curve is well known as a kind of You should start (0, 0), (100, 0) as the first segment.
|
def koch_curve(n, x1, y1, x2, y2):
if n == 0:
return [(x1, y1), (x2, y2)]
s_x = (2 * x1 + x2) / 3
s_y = (2 * y1 + y2) / 3
t_x = (x1 + 2 * x2) / 3
t_y = (y1 + 2 * y2) / 3
u_x = (t_x - s_x) * .5 - (t_y - s_y) * (3 ** .5 / 2) + s_x
u_y = (t_x - s_x) * (3 ** .5 / 2) + (t_y - s_y) * .5 + s_y
ret = koch_curve(n - 1, x1, y1, s_x, s_y) + \
koch_curve(n - 1, s_x, s_y, u_x, u_y) + \
koch_curve(n - 1, u_x, u_y, t_x, t_y) + \
koch_curve(n - 1, t_x, t_y, x2, y2)
return ret
for x, y in koch_curve(int(input()), 0, 0, 100, 0):
print('{:.4f} {:.4f}'.format(x, y))
|
s637710015
|
Accepted
| 20 | 6,184 | 685 |
def koch_curve(n, x1, y1, x2, y2):
if n == 0:
return [(x1, y1)]
s_x = (2 * x1 + x2) / 3
s_y = (2 * y1 + y2) / 3
t_x = (x1 + 2 * x2) / 3
t_y = (y1 + 2 * y2) / 3
u_x = (t_x - s_x) * .5 - (t_y - s_y) * (3 ** .5 / 2) + s_x
u_y = (t_x - s_x) * (3 ** .5 / 2) + (t_y - s_y) * .5 + s_y
ret = koch_curve(n - 1, x1, y1, s_x, s_y) + \
koch_curve(n - 1, s_x, s_y, u_x, u_y) + \
koch_curve(n - 1, u_x, u_y, t_x, t_y) + \
koch_curve(n - 1, t_x, t_y, x2, y2)
return ret
for x, y in koch_curve(int(input()), 0, 0, 100, 0):
print('{:.8f} {:.8f}'.format(x, y))
print('{:.8f} {:.8f}'.format(100, 0))
|
s709507784
|
p03624
|
u878138257
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 214 |
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
s = input()
listA = ["a","b","c","d","e","f","g","h","i","j","k",
"l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(27):
if s.count("listA[i]")==0:
print(listA[i])
break
|
s681236657
|
Accepted
| 20 | 3,188 | 249 |
s = input()
x=0
listA = ["a","b","c","d","e","f","g","h","i","j","k",
"l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(26):
if s.count(listA[i])==0:
print(listA[i])
x=1
break
if x==0:
print("None")
|
s956538354
|
p03377
|
u052347048
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 158 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
lis = input().split()
if int(lis[0]) > int(lis[2]):
print("No")
else:
print("Yes") if int(lis[0]) + int(lis[1]) >= int(lis[2]) else print("No")
|
s442520042
|
Accepted
| 17 | 2,940 | 159 |
lis = input().split()
if int(lis[0]) > int(lis[2]):
print("NO")
else:
print("YES") if int(lis[0]) + int(lis[1]) >= int(lis[2]) else print("NO")
|
s114680415
|
p02388
|
u077284614
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,416 | 14 |
Write a program which calculates the cube of a given integer x.
|
x=2;
y=x*x*x
y
|
s226317919
|
Accepted
| 20 | 7,660 | 26 |
x=int(input())
print(x**3)
|
s373641818
|
p02697
|
u141786930
| 2,000 | 1,048,576 |
Wrong Answer
| 76 | 9,276 | 175 |
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
|
# E - Rotation Matching
N, M = map(int, input().split())
if N%2==0:
for i in range(M):
print(i+1, N-(i))
else:
for i in range(M):
print(i+1, N-(i+1))
|
s889581999
|
Accepted
| 83 | 9,168 | 275 |
# E - Rotation Matching
N, M = map(int, input().split())
if N%2:
for i in range(M):
print(i+1, N-(i))
else:
for i in range(M):
if (i+1)+(N-(N-(i+1))) < N-(i+1)-(i+1):
print(i+1, N-(i+1))
else:
print(i+2, N-(i+1))
|
s380907275
|
p03360
|
u811000506
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 97 |
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?
|
n = list(map(int,input().split()))
k = int(input())
n.sort(reverse=True)
print(n[0]**k+n[1]+n[2])
|
s606240494
|
Accepted
| 18 | 2,940 | 135 |
li = list(map(int,input().split()))
k=int(input())
li.sort(reverse=True)
for i in range(k):
li[0] = li[0]*2
print(li[0]+li[1]+li[2])
|
s281863376
|
p02402
|
u613278035
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 112 |
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
input()
a = list(map(int,input().split()))
a.reverse()
str = ""
for d in a:
str += "%d "%(d)
print(str[:-1])
|
s173157285
|
Accepted
| 20 | 6,548 | 98 |
input()
a = list(map(int,input().split()))
sum = 0
for x in a:
sum+=x
print(min(a),max(a),sum)
|
s977604163
|
p03644
|
u197300260
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 528 |
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.
|
# Python 2nd Try
def solver(givenNumber):
answer = 0
for j in range(0, givenNumber):
counter = 0
baseNumber = j + 1
while True:
if baseNumber % 2 == 0:
counter = counter + 1
baseNumber = baseNumber / 2
else:
break
if answer <= counter:
counter = answer
return answer
if __name__ == "__main__":
N = int(input())
print(solver(N))
|
s758692801
|
Accepted
| 18 | 3,188 | 632 |
# python 3rd Try
import sys
def twoDividedCounter(N):
answer = 0
copyNumber = N
while True:
if copyNumber % 2 == 0:
answer = answer + 1
copyNumber = copyNumber / 2
else:
break
return answer
def solver(N):
answer = 1
counter = 0
for j in range(1, N+1):
jcount = twoDividedCounter(j)
if counter < jcount:
answer = j
counter = jcount
return answer
if __name__ == "__main__":
N = sys.stdin.readline().rsplit()
print(solver(int(N[0])))
|
s402781881
|
p02401
|
u609407244
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,740 | 78 |
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
|
while 1:
t = input()
if t == '0 ? 0':
break
print(eval(t))
|
s605702901
|
Accepted
| 30 | 6,732 | 79 |
while 1:
t = input()
if '?' in t:
break
print(int(eval(t)))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.