output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Evaluate the formula and print the result. * * *
s403229517
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = input().split() if op = '+': ans = int(a)+int(b) else: ans = int(a) - int(b) print(ans)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s452478777
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
li = list(map(int,input().split())) x = int(li[0]) y = int(li[2]) if li[1] = "+" print(x+y) else print(x-y)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s940739016
Accepted
p03844
The input is given from Standard Input in the following format: A op B
print(str(eval(input())))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s728537511
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = input().split() a = int(a) b = int(b) print(a op b)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s654767600
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A = input() B = input() op = + or - print(int(A) + op + int(B))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s428645588
Accepted
p03844
The input is given from Standard Input in the following format: A op B
f = input().split(" ") if f[1] == "+": print(int(f[0]) + int(f[2])) elif f[1] == "-": print(int(f[0]) - int(f[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s870895452
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
l = input().split() if l[1] = "+": print(int(l[0])+int(l[2])) else: print(int(l[0])-int(l[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s167497933
Accepted
p03844
The input is given from Standard Input in the following format: A op B
import sys import math cadena = list() sub = list() sub2 = list() s = """ Since <fontstyle="vertical−align:inherit;"><fontstyle="vertical−align:inherit;">1+2=3<⁄font><⁄font>, the output should be <fontstyle="vertical−align:inherit;"><fontstyle="vertical−align:inherit;">3<⁄font><⁄font>.""" salida = """<fontstyle="vertical−align:inherit;"><fontstyle="vertical−align:inherit;">3<⁄font><⁄font>.""" kl = salida.find(">3<") x = s.split() j = s.find("1+2=3") l = s.find(">3<") sub2.append(s[l + 1]) sub.append(s[j : j + 5]) c = sub[0] from itertools import permutations lines = sys.stdin.readlines() for linea in lines: c = linea.split() c = list(map(str, c)) x1 = int(c[0]) x2 = int(c[2]) operador = c[1] if operador == "+": op = x1 + x2 if operador == "-": op = x1 - x2 elif operador == "*": op = x1 * x2 if operador == "/": op = x1 / x2 str(op) operacion1 = s[j : j + 2] my_lst_str = "".join(map(str, c)) operacion1 = s[j : j + 3] men = s.replace(operacion1, my_lst_str) s = men numero = s[j + 4] men1 = salida.replace(salida[74], str(op)) men = s.replace(numero, str(op)) print(op)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s834480420
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
S=input().split(“ “) A=int(S[0]) B=int(S[2]) C=S[1] if S[1]==“+” print(A+B) if S[1]==“-” print(A-B)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s764969592
Accepted
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = (str(_) for _ in input().split()) print(int(a) + int(b)) if op == "+" else print(int(a) - int(b))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s643990721
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A,op,B=list(map(int, input().split())) if op==+: print(A+B) else: print(A-B)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s847629906
Accepted
p03844
The input is given from Standard Input in the following format: A op B
print(eval("".join(input().split())))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s614886373
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
>>>2+2
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s387735898
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
print(eval(input().split()))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s963884651
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, b, c = map(str, input().split()) if b == '+': print(int(a) + int(b)) else if b =='-': print(int(a) - int(b)) else: print("Error")
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s631967957
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a = list(map(str, input().split())) if a[1] == “+”: print(int(a[0]) + int(a[2])) else: print(int(a[0]) - int(a[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s679370492
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a = list(map(str, input().split())) if a[1] == “+”: print(int(a[0]) + int(a[2])) else: print(int(a[0]) - int(a[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s180405260
Accepted
p03844
The input is given from Standard Input in the following format: A op B
op = ["-", "+"] line = input().split(" ") s = 1 if line[1] == op[0]: s = -1 print(int(line[0]) + (int(line[2]) * s))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s635102774
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = input().split() if(op == "+"): print(int(a)+int(b)) else: print(int(a)-int(b)) 
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s304139534
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
print(eval(input())
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s480087159
Accepted
p03844
The input is given from Standard Input in the following format: A op B
L = list(input().split()) print(int(L[0]) + int(L[2]) if L[1] == "+" else int(L[0]) - int(L[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s026152510
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A, X, B= map(int, input().split()) P= A + B M= A - B print(P if X== str(-) else M )
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s222523822
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
int a,str b,int c = input().list() if b == "+": print(a+c) else: print(a-c)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s655979478
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A = input() B = input() op = input() if(op=='+'): print(A+B) if(op=='-') print(A-B)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s284117540
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a,op,b=map(str,input().split()) A=int(a) B=int(b) if op="+": print(A+B) else: print(A-B)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s767049296
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A, op, B = input().split() if op = '+': print(int(A) + int(B)) else: print(int(A) - int(B))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s106970349
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
st = input() print(int(st)) # Stay safe # IndiaFightsCorona # FightBack # StayHome # StaySafe
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s526650009
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = input().split() if op = '+': print(int(a)+int(b)) else: print(int(a)-int(b))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s259953850
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A, B= map(int(input().split)) OP= input() P= A + B M= A - B print(P if OP== + else M)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s018054004
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A, op, B = input(),split() if op = '+': print(A+B) if op = '-': print(A-B)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s737072290
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A op B = input().split() if op == "+": print(int(A)+int(B)) else: print(int(A)-int(B))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s778119250
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A , op , B = input().split() if op == "+": print(int(A) + int(B)) else: print(int(A) - int(B)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s556804843
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = input().split() if op = "+": print(int(a) + int(b)) else: print(int(a) - int(b))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s657763432
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = input().split() a = int(a) b = int(b) if op = '+': print(a + b) else: print(a - b)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s276132783
Accepted
p03844
The input is given from Standard Input in the following format: A op B
N = input() print(eval(N))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s340204220
Accepted
p03844
The input is given from Standard Input in the following format: A op B
func = eval(input()) print(func)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s654505422
Accepted
p03844
The input is given from Standard Input in the following format: A op B
x = input() print(eval(x))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s251831762
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
print(eval(input())
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s430465637
Wrong Answer
p03844
The input is given from Standard Input in the following format: A op B
print(input().replace(" ", ""))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s860914097
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = map(int, input().split()) print(a + b if op == + else a - b)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s253702687
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
[a,op,b]=list(input().split()) siki=a+op+b print(eval(siki))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s110849627
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
print(eval(input())
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s865173591
Wrong Answer
p03844
The input is given from Standard Input in the following format: A op B
print(input())
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s554547833
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
print(eval(input())
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s301804774
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
print(eval(*input()))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s072140726
Wrong Answer
p03844
The input is given from Standard Input in the following format: A op B
eval(input())
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s055006771
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, b, c = map(int, input().split()) print(a + b if op == + else a - b)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s650456208
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
input(eval(input()))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s726752829
Accepted
p03844
The input is given from Standard Input in the following format: A op B
shiki = input().split() if shiki[1] == "+": print(int(shiki[0]) + int(shiki[2])) elif shiki[1] == "-": print(int(shiki[0]) - int(shiki[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s576052533
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a,op,b = map(str, input().split()) if op == '+': result = a + b else op == '-': result = a - b print("{}".format(result))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s683484366
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int A = sc.nextInt(); String op = sc.next(); int B = sc.nextInt(); if (op.equals("+")){ System.out.println(A+B); } else{ System.out.println(A-B); } sc.close(); } }
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s821086045
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
N = int(input()) T = list(map(int, input().split())) M = int(input()) P, X = [], [] for i in range(M): p1, x1 = map(int, input().split()) P.append(p1) X.append(x1) count = 0 for i in T: count += T[i] c = count for i in X: count = c count += X[i] count -= T[i] print(count)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s940652151
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a = input().split() if a[1] == "+": print(int(a[0]) + int(a[2])) else a[1] == "-": print(int(a[0]) - int(a[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s537967340
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
s = list(map(str,input().split())) if s[1] == '+' print(int(s[0]) + int(s[2])) else: print(int(s[0]) - int(s[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s755665973
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
AB = list(map(str,input().split())) if AB[1] == "+" print(int(AB[0])+int(AB[2])) else: print(int(AB[0])-int(AB[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s720424327
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
MOD = int(1e9) + 7 N = int(input()) dp = [1,0,0] for i in range(64,-1,-1): ndp = [0,0,0] for d in range(3): nd = d*2 + (N>>>i&1) ndp[min(2,nd)] += dp[d] if nd >= 1: ndp[min(2,nd-1)] += dp[d] if nd >= 2: ndp[min(2,nd-2)] += dp[d] dp = ndp print(sum(dp) % MOD)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s693840328
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cmath> #include <stack> #include <queue> #include <numeric> #include <iomanip> #include <map> #include <set> #include <deque> #include <utility> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < n; i++) #define repk(i, k, n) for (int i = k; i < n; i++) #define MOD 1e9 + 7 #define INF 1e9 #define SENTINEL 2e9 #define PIE 3.14159265358979323 template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;} template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;} template <class T> inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);} template <class T> inline T LCM(T a, T b) {return (a * b) / GCD(a, b);} void ans(bool flag){ if (flag) cout << "Yes" << endl; else cout << "No" << endl; } int main(){ int a, b; string s; cin >> a >> s >> b; if (s=="+") cout << a + b << endl; else cout << a - b << endl; }
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s517226320
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a = input().split() if a[1] = "+": print(int(a[0]) + int(a[2])) if a[1] = "-": print(int(a[0]) - int(a[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s379083449
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
user_input = input("n a") input_sep = user_input.split() n = int(input_sep[0]) a = int(input_sep[1]) sum_out = 0 for num in range(0, n+1): sum_out += num*pow(a, num) print(str(sum_out))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s391534881
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
N = int(input()) T = list(map(int, input().split())) M = int(input()) P, X = [], [] for i in range(M): p1, x1 = map(int, input().split()) P.append(p1) X.append(x1) count = 0 for i in T: count += T[i] c = count for i in range(len(X)): count = c count += X[i] count -= T[i] print(count
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s565306719
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A op B=map(str,input().split()) if op=="+": print(int(A)+int(B)) else: print(int(A)-int(B))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s322485347
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A,op,B = [x for x in input().split()] A = int(A) B = int(B) if(op = '+'): print(A+B) else: print(A-B)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s863631448
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = map(str, input().split()) a = int(a) b = int(b) if op == "+": print(a + b) eles: print(a - b)
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s881929201
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
a, op, b = input().split() if op = '+': print(int(a) + int(b)) else: print(int(a) - int(b))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s071084195
Runtime Error
p03844
The input is given from Standard Input in the following format: A op B
A X B = map(int,input().split(' ')) if X == '+': print(int(A) + int(B)) else: print(int(A) - int(B))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Evaluate the formula and print the result. * * *
s285234077
Wrong Answer
p03844
The input is given from Standard Input in the following format: A op B
A = list(input().split()) print(A) print(int(A[0]) + int(A[2]) if A[1] == "+" else int(A[0]) - int(A[2]))
Statement Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
[{"input": "1 + 2", "output": "3\n \n\nSince 1 + 2 = 3, the output should be 3.\n\n* * *"}, {"input": "5 - 7", "output": "-2"}]
Print the resulting string. * * *
s692473330
Wrong Answer
p02756
Input is given from Standard Input in the following format: S Q Query_1 : Query_Q In the 3-rd through the (Q+2)-th lines, Query_i is one of the following: 1 which means T_i = 1, and: 2 F_i C_i which means T_i = 2.
S = input() for x in range(200000): try: q = input().split() if len(q) == 1: new_S = "" for n in list(range(len(S))): new_S = S[n] + new_S S = new_S elif len(q) == 3: f = int(q[1]) c = q[2] if f == 1: S = c + S elif f == 2: S += c except EOFError: break print(S)
Statement Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
[{"input": "a\n 4\n 2 1 p\n 1\n 2 2 c\n 1", "output": "cpa\n \n\nThere will be Q = 4 operations. Initially, S is `a`.\n\n * Operation 1: Add `p` at the beginning of S. S becomes `pa`.\n\n * Operation 2: Reverse S. S becomes `ap`.\n\n * Operation 3: Add `c` at the end of S. S becomes `apc`.\n\n * Operation 4: Reverse S. S becomes `cpa`.\n\nThus, the resulting string is `cpa`.\n\n* * *"}, {"input": "a\n 6\n 2 2 a\n 2 1 b\n 1\n 2 2 c\n 1\n 1", "output": "aabc\n \n\nThere will be Q = 6 operations. Initially, S is `a`.\n\n * Operation 1: S becomes `aa`.\n\n * Operation 2: S becomes `baa`.\n\n * Operation 3: S becomes `aab`.\n\n * Operation 4: S becomes `aabc`.\n\n * Operation 5: S becomes `cbaa`.\n\n * Operation 6: S becomes `aabc`.\n\nThus, the resulting string is `aabc`.\n\n* * *"}, {"input": "y\n 1\n 2 1 x", "output": "xy"}]
Print the resulting string. * * *
s972995006
Accepted
p02756
Input is given from Standard Input in the following format: S Q Query_1 : Query_Q In the 3-rd through the (Q+2)-th lines, Query_i is one of the following: 1 which means T_i = 1, and: 2 F_i C_i which means T_i = 2.
import glob # 問題ごとのディレクトリのトップからの相対パス REL_PATH = "ABC\\158\\D" # テスト用ファイル置き場のトップ TOP_PATH = "C:\\AtCoder" class Common: problem = [] index = 0 def __init__(self, rel_path): self.rel_path = rel_path def initialize(self, path): file = open(path) self.problem = file.readlines() self.index = 0 return def input_data(self): try: IS_TEST self.index += 1 return self.problem[self.index - 1] except NameError: return input() def resolve(self): pass def exec_resolve(self): try: IS_TEST for path in glob.glob(TOP_PATH + "\\" + self.rel_path + "/*.txt"): print("Test: " + path) self.initialize(path) self.resolve() print("\n\n") except NameError: self.resolve() class Solver(Common): def resolve(self): S = self.input_data().split()[0] Q = int(self.input_data()) query = [] zengo = True add_first = "" add_last = "" for i in range(Q): tmp = [j for j in self.input_data().split()] if tmp[0] == "1": query.append([1]) else: query.append([2, int(tmp[1]), tmp[2]]) for q in query: if q[0] == 1: zengo = not zengo else: if zengo: if q[1] == 1: add_first = q[2] + add_first else: add_last = add_last + q[2] else: if q[1] == 2: add_first = q[2] + add_first else: add_last = add_last + q[2] result = add_first + S + add_last if zengo: print(result) else: print(result[::-1]) solver = Solver(REL_PATH) solver.exec_resolve()
Statement Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
[{"input": "a\n 4\n 2 1 p\n 1\n 2 2 c\n 1", "output": "cpa\n \n\nThere will be Q = 4 operations. Initially, S is `a`.\n\n * Operation 1: Add `p` at the beginning of S. S becomes `pa`.\n\n * Operation 2: Reverse S. S becomes `ap`.\n\n * Operation 3: Add `c` at the end of S. S becomes `apc`.\n\n * Operation 4: Reverse S. S becomes `cpa`.\n\nThus, the resulting string is `cpa`.\n\n* * *"}, {"input": "a\n 6\n 2 2 a\n 2 1 b\n 1\n 2 2 c\n 1\n 1", "output": "aabc\n \n\nThere will be Q = 6 operations. Initially, S is `a`.\n\n * Operation 1: S becomes `aa`.\n\n * Operation 2: S becomes `baa`.\n\n * Operation 3: S becomes `aab`.\n\n * Operation 4: S becomes `aabc`.\n\n * Operation 5: S becomes `cbaa`.\n\n * Operation 6: S becomes `aabc`.\n\nThus, the resulting string is `aabc`.\n\n* * *"}, {"input": "y\n 1\n 2 1 x", "output": "xy"}]
Print the resulting string. * * *
s794394559
Wrong Answer
p02756
Input is given from Standard Input in the following format: S Q Query_1 : Query_Q In the 3-rd through the (Q+2)-th lines, Query_i is one of the following: 1 which means T_i = 1, and: 2 F_i C_i which means T_i = 2.
S = input() Q = int(input()) T = [0] * Q for i in range(0, Q): T[i] = list(map(str, input().split())) check = 0 for i in reversed(range(0, Q)): if T[i][0] != "1": check = i break nS = "" for i in range(0, check): if i != Q - 1 and T[i][0] == "1" and T[i + 1][0] == "1": T[i][0] = 0 T[i + 1][0] = 0 elif T[i][0] == "2" and T[i][1] == "1": S = T[i][2] + S elif T[i][0] == "2" and T[i][1] == "2": S = S + T[i][2] elif T[i][0] == "1": S = S[::-1] elif T[i][0] == 0: pass for i in range(check, Q): if i != Q - 1 and T[i][0] == "1" and T[i + 1][0] == "1": T[i][0] = 0 T[i + 1][0] = 0 elif T[i][0] == "1": S = S[::-1] elif T[i][0] == 0: pass print(S)
Statement Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
[{"input": "a\n 4\n 2 1 p\n 1\n 2 2 c\n 1", "output": "cpa\n \n\nThere will be Q = 4 operations. Initially, S is `a`.\n\n * Operation 1: Add `p` at the beginning of S. S becomes `pa`.\n\n * Operation 2: Reverse S. S becomes `ap`.\n\n * Operation 3: Add `c` at the end of S. S becomes `apc`.\n\n * Operation 4: Reverse S. S becomes `cpa`.\n\nThus, the resulting string is `cpa`.\n\n* * *"}, {"input": "a\n 6\n 2 2 a\n 2 1 b\n 1\n 2 2 c\n 1\n 1", "output": "aabc\n \n\nThere will be Q = 6 operations. Initially, S is `a`.\n\n * Operation 1: S becomes `aa`.\n\n * Operation 2: S becomes `baa`.\n\n * Operation 3: S becomes `aab`.\n\n * Operation 4: S becomes `aabc`.\n\n * Operation 5: S becomes `cbaa`.\n\n * Operation 6: S becomes `aabc`.\n\nThus, the resulting string is `aabc`.\n\n* * *"}, {"input": "y\n 1\n 2 1 x", "output": "xy"}]
Print the resulting string. * * *
s868007791
Wrong Answer
p02756
Input is given from Standard Input in the following format: S Q Query_1 : Query_Q In the 3-rd through the (Q+2)-th lines, Query_i is one of the following: 1 which means T_i = 1, and: 2 F_i C_i which means T_i = 2.
A = input() B = int(input()) C = "" for i in range(B): D = input().split() if D[0] == "1": A, C = C, A else: if D[1] == "1": A += D[2] else: C += D[2] A = A[::-1] print(A + C)
Statement Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
[{"input": "a\n 4\n 2 1 p\n 1\n 2 2 c\n 1", "output": "cpa\n \n\nThere will be Q = 4 operations. Initially, S is `a`.\n\n * Operation 1: Add `p` at the beginning of S. S becomes `pa`.\n\n * Operation 2: Reverse S. S becomes `ap`.\n\n * Operation 3: Add `c` at the end of S. S becomes `apc`.\n\n * Operation 4: Reverse S. S becomes `cpa`.\n\nThus, the resulting string is `cpa`.\n\n* * *"}, {"input": "a\n 6\n 2 2 a\n 2 1 b\n 1\n 2 2 c\n 1\n 1", "output": "aabc\n \n\nThere will be Q = 6 operations. Initially, S is `a`.\n\n * Operation 1: S becomes `aa`.\n\n * Operation 2: S becomes `baa`.\n\n * Operation 3: S becomes `aab`.\n\n * Operation 4: S becomes `aabc`.\n\n * Operation 5: S becomes `cbaa`.\n\n * Operation 6: S becomes `aabc`.\n\nThus, the resulting string is `aabc`.\n\n* * *"}, {"input": "y\n 1\n 2 1 x", "output": "xy"}]
Print the resulting string. * * *
s000456798
Wrong Answer
p02756
Input is given from Standard Input in the following format: S Q Query_1 : Query_Q In the 3-rd through the (Q+2)-th lines, Query_i is one of the following: 1 which means T_i = 1, and: 2 F_i C_i which means T_i = 2.
print("xy")
Statement Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
[{"input": "a\n 4\n 2 1 p\n 1\n 2 2 c\n 1", "output": "cpa\n \n\nThere will be Q = 4 operations. Initially, S is `a`.\n\n * Operation 1: Add `p` at the beginning of S. S becomes `pa`.\n\n * Operation 2: Reverse S. S becomes `ap`.\n\n * Operation 3: Add `c` at the end of S. S becomes `apc`.\n\n * Operation 4: Reverse S. S becomes `cpa`.\n\nThus, the resulting string is `cpa`.\n\n* * *"}, {"input": "a\n 6\n 2 2 a\n 2 1 b\n 1\n 2 2 c\n 1\n 1", "output": "aabc\n \n\nThere will be Q = 6 operations. Initially, S is `a`.\n\n * Operation 1: S becomes `aa`.\n\n * Operation 2: S becomes `baa`.\n\n * Operation 3: S becomes `aab`.\n\n * Operation 4: S becomes `aabc`.\n\n * Operation 5: S becomes `cbaa`.\n\n * Operation 6: S becomes `aabc`.\n\nThus, the resulting string is `aabc`.\n\n* * *"}, {"input": "y\n 1\n 2 1 x", "output": "xy"}]
Print the resulting string. * * *
s088638245
Wrong Answer
p02756
Input is given from Standard Input in the following format: S Q Query_1 : Query_Q In the 3-rd through the (Q+2)-th lines, Query_i is one of the following: 1 which means T_i = 1, and: 2 F_i C_i which means T_i = 2.
Statement Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure.
[{"input": "a\n 4\n 2 1 p\n 1\n 2 2 c\n 1", "output": "cpa\n \n\nThere will be Q = 4 operations. Initially, S is `a`.\n\n * Operation 1: Add `p` at the beginning of S. S becomes `pa`.\n\n * Operation 2: Reverse S. S becomes `ap`.\n\n * Operation 3: Add `c` at the end of S. S becomes `apc`.\n\n * Operation 4: Reverse S. S becomes `cpa`.\n\nThus, the resulting string is `cpa`.\n\n* * *"}, {"input": "a\n 6\n 2 2 a\n 2 1 b\n 1\n 2 2 c\n 1\n 1", "output": "aabc\n \n\nThere will be Q = 6 operations. Initially, S is `a`.\n\n * Operation 1: S becomes `aa`.\n\n * Operation 2: S becomes `baa`.\n\n * Operation 3: S becomes `aab`.\n\n * Operation 4: S becomes `aabc`.\n\n * Operation 5: S becomes `cbaa`.\n\n * Operation 6: S becomes `aabc`.\n\nThus, the resulting string is `aabc`.\n\n* * *"}, {"input": "y\n 1\n 2 1 x", "output": "xy"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s180178388
Accepted
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
import sys sys.setrecursionlimit(10**6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(input()) def MI(): return map(int, input().split()) def MI1(): return map(int1, input().split()) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def printlist(lst, k="\n"): print(k.join(list(map(str, lst)))) INF = float("inf") from collections import deque def solve(): n = II() H = LI() d = deque() def split_0(lst): res = [] tmp = [] for l in lst: if l == 0: if len(tmp) > 0: res.append(tmp) tmp = [] else: tmp.append(l) if len(tmp) > 0: res.append(tmp) return res r = split_0(H) d.extend(r) # print(d) cnt = 0 while len(d) > 0: lst = d.popleft() mn = min(lst) res = split_0(list(map(lambda x: x - mn, lst))) cnt += mn d.extend(res) print(cnt) if __name__ == "__main__": solve()
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s239500009
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
import sys def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 10 ** 9 + 7 n = I() hl = LI() # count = 0 # len_h = len(hl) # def m1(n): # if n > 0: # n = n - 1 # else: # n = 0 # return n # max_hana = max(hl) # if max_hana == 0: # print(0) # sys.exit() # for i in range(max_hana): # for j in range(len_h): # if j == 0: # if hl[j] > 0: # count += 1 # else: # if hl[j] > 0 and hl[j-1] == 0: # count += 1 # elif hl[j] > 0 and hl[j-1] == 0: # count += 1 # hl = list(map(m1, hl)) # print(count) ###################### # 隣との差分を考えたほうが早い # 1 2 4 2 1 0 計4 # 1 2 0 0 0 ans = hl[0] for i in range(1, n) ans += max(0, hl[i] - hl[i - 1]) print(ans)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s327492537
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
import sys def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 10 ** 9 + 7 n = I() hl = LI() # count = 0 # len_h = len(hl) # def m1(n): # if n > 0: # n = n - 1 # else: # n = 0 # return n # max_hana = max(hl) # if max_hana == 0: # print(0) # sys.exit() # for i in range(max_hana): # for j in range(len_h): # if j == 0: # if hl[j] > 0: # count += 1 # else: # if hl[j] > 0 and hl[j-1] == 0: # count += 1 # elif hl[j] > 0 and hl[j-1] == 0: # count += 1 # hl = list(map(m1, hl)) # print(count) ###################### # 隣との差分を考えたほうが早い # 1 2 4 2 1 0 計4 # 1 2 0 0 0 ans = hl[0] for i in range(1, N) ans += max(0, hl[i] - hl[i - 1]) print(ans)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s688316847
Accepted
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
N, *h = map(int, open(0).read().split()) ans = sum([max(h[i + 1] - h[i], 0) for i in range(N - 1)]) print(ans + h[0])
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s836786992
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
難しい...
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s817878933
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
n=int(input()) h=list(map(int,input.split())) hm=max(h) t=1 ans=0 for i in range(hm,-1,-1): for j in range(n): if h[j]=i: ans+=t t=0 else: t=1 print(ans)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s577152052
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
n=int(input()) h=list(map(int,input.split())) hm=max(h) t=1 for i in range(hm,-1,-1): for j in range(n): if h[j]=i: ans+=t t=0 else: t=1 print(ans)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s140441314
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
n=int(input()) h=list(map(int,input.split())) hm=max(h) t=1 for i in range(hm,-1,-1): for j in range(n) if h[j]=i: ans+=t t=0 else: t=1 print(ans)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s144781215
Wrong Answer
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
n = int(input()) h_L = list(map(int, input().split())) print(sum(h_L))
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s245545859
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
N = int(input()) Hlst = list(map(int, input().split())) times = 0 l = 0 r = l while r <= N: l = r while Hlst[r] == 1: r += 1 for water in range(l, r + 1): Hlst[water] -= 1 times += 1 print(times)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s984344963
Wrong Answer
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
n = int(input()) listH = list(map(int, input().split())) minH = min(listH) indexF = 0 while indexF < len(listH): listH[indexF] -= minH indexF += 1 sum = minH def getZeroIndex(listH): listZeroIndex = [] index = 0 while index < len(listH): if listH[index] == 0: listZeroIndex.append(index) index += 1 return listZeroIndex def mizuyari(listH, listZeroIndex, sum): if not 0 in listZeroIndex: index = 0 nextMin = 100 while index < listZeroIndex[0]: if nextMin > listH[index] and listH[index] != 0: nextMin = listH[index] index += 1 index = 0 sum += nextMin while index < listZeroIndex[0]: listH[index] -= nextMin index += 1 index2 = 0 while index2 < len(listZeroIndex) - 1: nextMin = 100 index3 = listZeroIndex[index2] + 1 if index3 == listZeroIndex[index2 + 1]: pass else: while index3 < listZeroIndex[index2 + 1]: if nextMin > listH[index3] and listH[index3] != 0: nextMin = listH[index3] index3 += 1 index3 = listZeroIndex[index2] + 1 sum += nextMin while index3 < listZeroIndex[index2 + 1]: listH[index3] -= nextMin index3 += 1 index2 += 1 if listZeroIndex[len(listZeroIndex) - 1] != len(listH) - 1: index4 = listZeroIndex[len(listZeroIndex) - 1] + 1 nextMin = 100 while index4 < len(listH): if listH[index4] < nextMin: nextMin = listH[index4] index4 += 1 index4 = listZeroIndex[len(listZeroIndex) - 1] + 1 sum += nextMin while index4 < len(listH): listH[index4] -= nextMin index4 += 1 return listH, sum index5 = 0 while index5 < 10: listZeroIndex = getZeroIndex(listH) listH, sum = mizuyari(listH, listZeroIndex, sum) if len(listH) == len(listZeroIndex): break index5 += 1 print(sum)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s145716462
Wrong Answer
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
from itertools import zip_longest from collections import deque N = int(input()) heights = tuple(map(int, input().split(" "))) heights = [ h1 for h1, h2 in zip_longest(heights, heights[1:], fillvalue=None) if h1 != h2 ] if len(heights) <= 2: print(max(heights)) else: tops = deque() bottoms = deque() if heights[0] > heights[1]: tops.append(heights[0]) for i in range(1, len(heights) - 1): if heights[i - 1] < heights[i] and heights[i] > heights[i + 1]: tops.append(heights[i]) elif heights[i - 1] > heights[i] and heights[i] < heights[i + 1]: bottoms.append(heights[i]) if heights[-1] > heights[-2]: tops.append(heights[-1]) if len(bottoms) == 0: print(tops[0]) else: bottoms.appendleft(bottoms[0]) bottoms.append(bottoms[-1]) cost = min(bottoms) for index, top in enumerate(tops): left = bottoms[index] right = bottoms[index + 1] cost += top - min(left, right) print(cost)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s801703692
Accepted
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
N = int(input()) a = list(map(int, input().split())) b = [] i = 0 while sum(a) != 0: for j in range(len(a)): if a[j] != 0: b.append(j) a[j] -= 1 for k in range(len(b) - 1): if b[k + 1] - b[k] != 1: i += 1 i += 1 b = [] print(i)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s889659132
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
#! /usr/bin/env python3 # -*- coding: utf-8 -*- N = input() h = [int(x) for x in input().split()] count = 0 while sum(h) == 0: htop = [x-(max(h)-1) if x-(max(h) >= 0) else 0 for x in h] h = [x-1 if x-1 >= 0 else 0 for x in h] htop = "".join(h) htop = htop.split("1") count += len(htop)-1 print(count)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s625197550
Accepted
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
N = int(input()) hs = [int(val) for val in input().split(" ")] # num = len(hs) # start_idx = None # end_idx = None # op_num = 0 # last_op_idx = None # while sum(hs) > 0: # for i in range(num): # if hs[i] > 0: # hs[i] -= 1 # last_op_idx = i # if i == num - 1: # op_num += 1 # else: # if i >= 1 and last_op_idx == i-1: # op_num += 1 # print(op_num) def recursion(hs, op_num): if not hs: return op_num - 1 if min(hs) >= 1: return recursion([val - 1 for val in hs], op_num + 1) results = [] curr_results = [] for i in range(len(hs)): if hs[i] >= 1: curr_results.append(hs[i] - 1) else: results.append(curr_results) curr_results = [] results.append(curr_results) for result in results: op_num += recursion(result, 1) return op_num print(recursion(hs, 0))
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s256807533
Wrong Answer
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
import sys sys.setrecursionlimit(1000) n = int(input()) H = list(map(int, input().split())) def bunkai(H): B = [] b = 0 f = 0 for i in range(len(H)): if H[i] == 0: if i != 0: B.append(H[b : i - 1 + 1]) b = i + 1 else: b = i + 1 elif i == len(H) - 1: B.append(H[b:]) return B def min(lis): min = 999999999999999 for i in range(len(lis)): if lis[i] < min: min = lis[i] return min def mizu(lis, n): for i in range(len(lis)): lis[i] += -n return lis def sso(lis, sum): # print(sum) B = bunkai(lis) # print(B) if len(B) == 0: # print("return: "+str(sum)) return sum for l in B: # print(l) x = min(l) sum += x li = mizu(l, x) sum = sso(li, sum) # print("return end:"+str(sum)) return sum sum = 0 x = sso(H, sum)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s335868097
Accepted
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
flowers_num = int(input()) target_heights = list(map(int, input().split())) max_height = max(target_heights) watering_sum = 0 for row_i in range(1, max_height + 1): should_water = False for target_height in target_heights: if row_i <= target_height: should_water = True elif should_water: watering_sum += 1 should_water = False if should_water: watering_sum += 1 should_water = False print(watering_sum)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s863372673
Wrong Answer
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
s = int(input()) a = [] a.append(s) for i in range(1, 1000000): if a[i - 1] % 2 == 0: a.append(a[i - 1] / 2) else: a.append(3 * a[i - 1] + 1) for j in range(i - 1, -1, -1): if a[j] == a[i]: print(int(i + 1)) exit()
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s347775733
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
#! /usr/bin/env python3 # -*- coding: utf-8 -*- N = input() h = "".join(input().split()) # h は数字の文字列 count = 0 while sum([int(x) for x in h]) != 0: h2 = [x for x in h.strip("0").split("0")] count += len(h2) h3 = ""join.h2 h = [int(x)-1 for x in h3] print(count)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s348735259
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
n=int(input()) h=list(map(int,input().split())) f=[0]*n cnt=0 while 1: flag=0 for i in range(n): if h[i]!=f[i]: f[i]+=1 flag=1 elif h[i]==f[i] and flag==1: cnt+=1 flag=0 if flag:==1 cnt+=1 if h == f: break print(cnt)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s507653024
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
#! /usr/bin/env python3 # -*- coding: utf-8 -*- N = input() h = [int(x) for x in input().split()] count = 0 while sum(h) == 0: htop = [x-(max(h)-1) if x-(max(h) >= 0) else 0 for x in h] h = [x-1 if x-1 >= 0 else 0 for x in h] count += len(h.split("".join(htop)))-1 print(count)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s709079818
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
#! /usr/bin/env python3 # -*- coding: utf-8 -*- N = input() h = [int(x) for x in input().split()] count = 0 while sum(h) == 0: htop = [x-(max(h)-1) if x-(max(h) >= 0) else 0 for x in h] h = [x-1 if x-1 >= 0 else 0 for x in h] htop = "".join(htop) htop = htop.split("1") count += len(htop)-1 print(count)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s695721958
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
= int(input()) h = list(map(int, input().split())) ans = 0 cnt = 0 for i in range(1, max(h) + 1)[::-1]: cnt = 0 for j in range(n): if h[j] == i: h[j] -= 1 cnt += 1 if j + 1 < n: if h[j + 1] == i: cnt -= 1 ans += cnt print(ans)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s274807852
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
num = int(input()) targets = map(int, input().split()) targets = list(targets) water_cnt = 0 def exe_water(init_state): # break condition if sum(init_state) == 0: return temp_water_cnt = min(init_state) water_cnt += temp_water_cnt lowest = temp_water_cnt # init sub_state sub_state = [] for h in init_state: substracted_h = h - lowest if substracted_h != 0: sub_state.append(substracted_h) else: exe_water(sub_state) # reinit for next sequence sub_state = [] exe_water(targets) print(water_cnt)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s333787588
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
"main.py" 5L, 116C written def calc_watering_num(h, offset, left, right): if left > right: return 0 min_h = None min_h_indices = [] for i in range(left, right + 1): if min_h is None or min_h > h[i] - offset: min_h = h[i] - offset min_h_indices = [i] elif min_h == h[i] - offset: min_h_indices.append(i) if len(min_h_indices) == right - left + 1: return min_h num = min_h prev = left for i in min_h_indices: num += calc_watering_num(h, offset + min_h, prev, i - 1) prev = i + 1 num += calc_watering_num(h, offset + min_h, prev, right) return num input() h = [int(v) for v in input().split()] print(calc_watering_num(h, 0, 0, len(h) - 1))
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s473162024
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
N = int(input()) height = list(map(int,input().split())) ans = 0 interval = 0 for i in range(N): #区間が足りない時 if height[i] > interval:   #今の区間と必要な区間の差分を取って足し、新たな区間の数を定義する   ##順番に注意 先にintervalに定義すると、 ##ansがそれに影響されるためansが差分の分だけ余分にに大きくなる ans += height[i] - interval interval += height[i] - interval #区間が多い時、必要な数に減らす else: interval = height[i] print(ans)
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s057324375
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> using namespace std; typedef long long ll; typedef long long int llint; typedef pair<ll, ll> pa; #define MM 1000000000 #define MOD MM+7 #define MAX 101000 #define MAP 110 #define initial_value -1 #define Pair pair<int,int> #define chmax(a,b) (a<b ? a=b:0) #define chmin(a,b) (a>b ? a=b:0) #define INF (1 << 29) //536870912 int dx[4] = {-1,0,1,0}; int dy[4] = {0,-1,0,1}; int main(){ int n; cin >> n; int h[101]; cin >> h[0]; int ans = h[0]; for(int i = 1; i < n; i++){ cin >> h[i]; if(h[i] >= h[i-1]){ ans += (h[i] - h[i-1]); } } cout << ans << endl; }
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]
Print the minimum number of watering operations required to satisfy the condition. * * *
s022964373
Runtime Error
p03147
Input is given from Standard Input in the following format: N h_1 h_2 h_3 ...... h_N
print(int(input())
Statement In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers l and r. Increase the height of Flower x by 1 for all x such that l \leq x \leq r. Find the minimum number of watering operations required to satisfy the condition.
[{"input": "4\n 1 2 2 1", "output": "2\n \n\nThe minimum number of watering operations required is 2. One way to achieve it\nis:\n\n * Perform the operation with (l,r)=(1,3).\n * Perform the operation with (l,r)=(2,4).\n\n* * *"}, {"input": "5\n 3 1 2 3 1", "output": "5\n \n\n* * *"}, {"input": "8\n 4 23 75 0 23 96 50 100", "output": "221"}]