s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s135390253 | p03612 | u943004959 | 1504410491 | Python | Python (3.4.3) | py | Runtime Error | 64 | 14008 | 466 | def swap(a, b):
tmp = a
a = b
b = tmp
return a, b
def solve(): # 072D- Derangement
N = int(input())
p = list(map(int, input().split(" ")))
p.insert(0, 1)
cnt = 0
for i in range(1, N+1):
if i == p[i]:
p[i], p[i+1] = swap(p[i], p[i+1])
cnt += 1
... |
s279060139 | p03612 | u943004959 | 1504410062 | Python | Python (3.4.3) | py | Runtime Error | 52 | 14008 | 436 | def solve(): # 072D- Derangement
N = int(input())
p = list(map(int, input().split(" ")))
cnt = 0
for i in range(1, N):
if i == p[i-1]:
p[i], p[i+1] = swap(p[i], p[i+1])
cnt += 1
elif i == N:
p[i-1], p[i] = swap(p[i-1], p[i])
cnt += 1
... |
s799685275 | p03612 | u943004959 | 1504409969 | Python | Python (3.4.3) | py | Runtime Error | 58 | 13880 | 447 | def swap(a, b):
tmp = a
a = b
b = tmp
return a, b
def solve(): # 072D- Derangement
N = int(input())
p = list(map(int, input().split(" ")))
cnt = 0
for i in range(1, N):
if i == p[i-1]:
p[i], p[i+1] = swap(p[i], p[i+1])
cnt += 1
elif i == N:
... |
s118134710 | p03612 | u142415823 | 1504408337 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 352 | import sys
def main():
N = int(sys.stdin.readline())
p = list(map(int, input().split()))
count = 0
for i, n in enumerate(p, 1):
if i == n:
try:
count += 1
p[i - 1], p[i] = p[i], p[i - 1]
except:
break
print(count)
if __... |
s341319943 | p03612 | u642905089 | 1504408331 | Python | Python (3.4.3) | py | Runtime Error | 87 | 13940 | 374 | n = input()
a = list(map(int,input().split()))
a.insert(0,0.5)
alen = len(a)
a.append(0.5)
ans = 0
med = [0 for x in range(alen +1)]
for i in range(alen):
if a[i] == i:
med[i+1] = 1
for i in range(len(med)):
if med[i] == 1:
if med[i+1] == 1:
med[i+1] = 0
ans += 1
... |
s922390529 | p03612 | u642905089 | 1504408146 | Python | Python (3.4.3) | py | Runtime Error | 41 | 14008 | 371 | n = input()
a = list(map(int,input().split()))
a.insert(0.5)
alen = len(a)
a.append(0.5)
ans = 0
med = [0 for x in range(alen +1)]
for i in range(alen):
if a[i] == i:
med[i+1] = 1
for i in range(len(med)):
if med[i] == 1:
if med[i+1] == 1:
med[i+1] = 0
ans += 1
... |
s021199153 | p03612 | u142415823 | 1504407971 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 320 | def main():
N = int(sys.stdin.readline())
p = list(map(int, input().split()))
count = 0
for i, n in enumerate(p, 1):
if len(p) == i:
continue
if i == n:
p[i - 1], p[i] = p[i], p[i - 1]
count += 1
print(count)
if __name__ == '__main__':
main()
|
s056165384 | p03612 | u642905089 | 1504407961 | Python | Python (3.4.3) | py | Runtime Error | 96 | 14008 | 361 | n = input()
a = list(map(int,input().split()))
a.insert(0,0.5)
alen = len(a)
a.append(0.5)
ans = 0
med = [0 for x in range(alen +1)]
for i in range(alen):
if a[i] == i:
med[i+1] = 1
for i in range(len(med)):
if med[i] == 1:
if med[i+1] == 1:
med[i+1] = 0
ans += 1
e... |
s134747144 | p03612 | u642905089 | 1504407863 | Python | Python (3.4.3) | py | Runtime Error | 41 | 14008 | 359 | n = input()
a = list(map(int,input().split()))
a.insert(0.5)
alen = len(a)
a.append(0.5)
ans = 0
med = [0 for x in range(alen +1)]
for i in range(alen):
if a[i] == i:
med[i+1] = 1
for i in range(len(med)):
if med[i] == 1:
if med[i+1] == 1:
med[i+1] = 0
ans += 1
els... |
s729262548 | p03612 | u142415823 | 1504407850 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3056 | 342 | def main():
N = int(sys.stdin.readline())
p = list(map(int, input().split()))
count = 0
for i, n in enumerate(p, 1):
if i == n:
try:
p[i - 1], p[i] = p[i], p[i - 1]
count += 1
except:
break
print(count)
if __name__ == '... |
s542251946 | p03612 | u142415823 | 1504407789 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 338 | def main():
N = int(sys.stdin.readline())
p = list(map(int, input().split()))
count = 0
for i, n in enumerate(p, 1):
if i == n:
try:
p[i], p[i] = p[i], p[i - 1]
count += 1
except:
break
print(count)
if __name__ == '__ma... |
s188427057 | p03612 | u142415823 | 1504407756 | Python | Python (3.4.3) | py | Runtime Error | 16 | 2940 | 331 | def main():
N = int(sys.stdin.readline())
p = list(map(int, input().split()))
count = 0
for i, n in enumerate(p, 1):
if i == n:
try:
p[i], p[i] = p[i], p[i - 1]
count += 1
except:
break
print(count)
if __name__ == '__main__':
... |
s931221989 | p03612 | u142415823 | 1504407724 | Python | Python (3.4.3) | py | Runtime Error | 19 | 2940 | 330 | def main():
N = int(sys.stdin.readline())
p = list(map(int, input().split()))
count = 0
for i, n in enumerate(p, 1):
if i == n:
try:
p[i], p[i] = p[i], p[i - 1]
count += 1
except:
break
print(count)
if __name__ == '__main__':
... |
s868359542 | p03612 | u142415823 | 1504407591 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 275 | def main():
N = int(sys.stdin.readline())
p = list(map(int, input().split()))
count = 0
for i, n in enumerate(p, 1):
if i == n:
p[i - 1], p[i] = p[i], p[i - 1]
count += 1
print(count)
if __name__ == '__main__':
main()
|
s429861981 | p03612 | u952708174 | 1504407034 | Python | Python (3.4.3) | py | Runtime Error | 64 | 13880 | 448 | def D_Derangement(N, p):
count = 0
i = 0
while i < N:
if p[i] == i + 1:
if p[i + 1] == i + 2:
count += 1
i += 2
continue
else:
count += 1
i += 1
continue
else:
... |
s223356271 | p03612 | u642905089 | 1504406519 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 477 | def swap(a,b,c):
x = a[b]
a[b] = a[c]
a[c] = x
n = input()
a = list(map(int,input().split()))
alen = len(a)
a.append(0.5)
a.append(0.5)
ans = 0
med = [0 for x in range(alen +3)]
for i in range(alen):
if a[i] == i+1:
med[i+1] = 1
for i in range(len(med)):
if med[i] == 1:
i... |
s902079543 | p03612 | u642905089 | 1504406423 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 481 | def swap(a,b,c):
x = a[b]
a[b] = a[c]
a[c] = x
n = input()
a = list(map(int,input().split()))
alen = len(a)
a.append(0.5)
a.append(0.5)
ans = 0
med = [0 for x in range(alen +3)]
for i in range(alen):
if a[i] == i+1:
med[i+1] = 1
for i in range(len(med)):
if med[i] == 1:
if me... |
s721187048 | p03612 | u192908410 | 1504406316 | Python | Python (3.4.3) | py | Runtime Error | 70 | 14008 | 222 | N = int(input())
p = list(map(int,input().split()))
ret = 0
flag = 0
for i in range(len(p)):
if i + 1 == p[i]:
if flag == 0:
ret += 1
if p[i+1] == i+2:
flag = 1
else:
flag = 0
print(ret) |
s003955216 | p03612 | u190405389 | 1504406170 | Python | Python (3.4.3) | py | Runtime Error | 89 | 13880 | 285 | N = int(input())
p = [int(x) for x in input().split()]
l = []
for i in range(len(p)):
if p[i] == i + 1:
l.append(p[i])
else:
l.append(0)
count = 0
for i in range(len(l)):
if l[i] > 0:
l[i] = 0
l[i + 1] = 0
count += 1
print(count)
|
s709719113 | p03612 | u190405389 | 1504406078 | Python | Python (3.4.3) | py | Runtime Error | 70 | 13880 | 286 | N = int(input())
p = [int(x) for x in input().split()]
l = []
for i in range(len(p)):
if p[i] == i + 1:
l.append(p[i])
else:
l.append(0)
count = 0
for i in renge(len(l)):
if l[i] > 0:
l[i] = 0
l[i + 1] = 0
count += 1
print(count)
|
s057322253 | p03612 | u946386741 | 1504405590 | Python | Python (3.4.3) | py | Runtime Error | 45 | 14008 | 376 | N = int(input())
P1 = [0] + list(map(int, input().split()))
P2 = [0] + list(map(int, input().split()))
res1 = 0
for i in range(1, len(P1) - 1):
if i == P1[i]:
P1[i], P1[i + 1] = P1[i + 1], P1[i]
res1 += 1
res2 = 0
for i in range(len(P2)-1, 1, -1):
if i == P2[i]:
P2[i], P2[i - 1] = P2[i... |
s881231029 | p03612 | u946386741 | 1504405307 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14008 | 322 | N = int(input())
P = [0] + list(map(int, input().split()))
res1 = 0
for i in range(1, len(P) - 1):
if i == P[i]:
P[i], P[i + 1] = P[i + 1], P[i]
res1 += 1
res2 = 0
for i in range(len(P), 1 + 1, -1):
if i == P[i]:
P[i], P[i - 1] = P[i - 1], P[i]
res2 += 1
print(min(res1, res2))... |
s513062311 | p03612 | u485435834 | 1504404775 | Python | Python (3.4.3) | py | Runtime Error | 84 | 14008 | 272 | N = int(input())
p_list = list(map(int, input().split()))
i = 0
count = 0
while i < N:
if p_list[i] == i + 1:
temp = p_list[i+1]
p_list[i+1] = p_list[i]
p_list[i] = temp
count = count + 1
i = i + 1
i = i + 1
print(count)
|
s879372134 | p03612 | u803848678 | 1504404460 | Python | Python (3.4.3) | py | Runtime Error | 1557 | 14008 | 244 | N = int(input())
p = list(map(int, input().split()))
count = 0
now = 0
for i in range(len(p)):
if len(p) == 0:
break
if now+1 == p[0]:
p.pop(0)
count += 1
now += 1
p.pop(0)
now += 1
print(count)
|
s068048749 | p03612 | u833492079 | 1504404139 | Python | Python (3.4.3) | py | Runtime Error | 77 | 14520 | 375 | N = int(input()) # 5
#a = [int(i) for i in input().split()] # 1 2 3 4 5 ...
s = "0 " + input()
a = [int(i) for i in s.split()] # 1 2 3 4 5 ...
N = len(a)
#print(a)
ans = 0
bSkip = False
for i in range(N):
if i==0: continue;
if bSkip:
bSkip = False
continue;
# print(i, a[i])
if i==a[i]:
ans += 1
if(... |
s925759556 | p03612 | u833492079 | 1504404049 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14520 | 362 | N = int(input()) # 5
#a = [int(i) for i in input().split()] # 1 2 3 4 5 ...
s = "0 " + input()
a = [int(i) for i in s.split()] # 1 2 3 4 5 ...
N = len(a)
#print(a)
ans = 0
bSkip = False
for i in range(N):
if i==0: continue;
if bSkip:
bSkip = False
continue;
# print(i, a[i])
if i==a[i]:
ans += 1
if(... |
s339738578 | p03612 | u820351940 | 1504404003 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 236 | n = int(input())
b = list(range(n**2))
a = list(map(int, input().split()))
flg = False
cnt = 0
for i, v in enumerate(a, 1):
if flg:
flg = False
continue
if i is v:
cnt += 1
flg = True
print(cnt)
|
s016060142 | p03612 | u218984487 | 1504403811 | Python | Python (3.4.3) | py | Runtime Error | 117 | 16900 | 286 | import sys
sys.setrecursionlimit(10000)
N = int(input())
p = list(map(int, input().split()))
def solve(i, c):
if i == N - 1:
return c
if p[i] == i+1:
a = p[i]
p[i] = p[i+1]
p[i+1] = a
c += 1
return solve(i+1, c)
print(solve(0, 0))
|
s601141376 | p03612 | u096190786 | 1504403659 | Python | Python (2.7.6) | py | Runtime Error | 85 | 11344 | 793 | #!/usr/bin/python
import sys
def main(argv):
line = sys.stdin.readline()
while line:
N = int(line)
P = map(lambda x: int(x), sys.stdin.readline().split(" "))
counter = 0
for i in xrange(len(P)):
index = i + 1
if P[i] == index:
if i > 0:
... |
s870196847 | p03612 | u218984487 | 1504403275 | Python | Python (3.4.3) | py | Runtime Error | 98 | 14008 | 244 | N = int(input())
p = list(map(int, input().split()))
def solve(i, c):
if i == N - 1:
return c
if p[i] == i+1:
a = p[i]
p[i] = p[i+1]
p[i+1] = a
c += 1
return solve(i+1, c)
print(solve(0, 0)) |
s833656891 | p03612 | u565438743 | 1504402817 | Python | Python (3.4.3) | py | Runtime Error | 25 | 10484 | 207 | import sys
n = int (sys.stdin.readline())
a = map (int, sys.stdin.readline().split())
res = 0
for i in range (n):
if a[i] == i+1:
if i+1 < n:
a[i], a[i+1] = a[i+1], a[i]
res += 1
print (res)
|
s866675952 | p03612 | u455591217 | 1504402337 | Python | Python (3.4.3) | py | Runtime Error | 70 | 14008 | 170 | N = int(input())
P = list(map(int, input().split(' ')))
num = 0
for i in range(len(P)):
if P[i] == i+1:
P[i],P[i+1] = P[i+1],P[i]
num += 1
print(num)
|
s057991476 | p03612 | u839537730 | 1504401919 | Python | Python (3.4.3) | py | Runtime Error | 84 | 14008 | 235 | N = int(input())
P = list(map(int, input().split()))
ans = 0
i = 0
while i < len(P):
if i+1 == P[i]:
if i+2 == P[i+1]:
ans += 1
i += 1
else:
ans += 1
i += 1
print(ans) |
s832845150 | p03613 | u984276646 | 1578082281 | Python | Python (3.4.3) | py | Runtime Error | 98 | 13964 | 205 | N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+1)]
for i in range(N):
L[A[i]] += 1
mL = []
for j in range(len(L)-2):
mL.append(L[j] + L[j+1] + L[j+2])
print(max(mL)) |
s850725109 | p03613 | u353895424 | 1575433576 | Python | Python (3.4.3) | py | Runtime Error | 97 | 17632 | 693 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
if len(set(a)) == 1:
print(n)
exit()
elif len(set(a)) == n:
print(3)
c = Counter(a)
mc = c.most_common()[0][0]
# if mc == 0:
# mc = c.most_common()[1][0]
# if 10**5 - 1 > mc > 1:
# ans = c.most_common()[0][1] + a... |
s612343341 | p03613 | u977193988 | 1566134232 | Python | Python (3.4.3) | py | Runtime Error | 173 | 14092 | 711 | n=int(input())
A=sorted(list(map(int,input().split())))
L={}
if n==1:
print(1)
elif n==2:
if abs(A[0]-A[1])==1:
print(2)
else:
print(1)
else:
for i in A:
if i not in L:
L[i]=1
else:
L[i]+=1
print(L)
ans=[]
for j in range(A[0],A[-1]+... |
s242174377 | p03613 | u977193988 | 1566133684 | Python | Python (3.4.3) | py | Runtime Error | 126 | 14064 | 449 | n=int(input())
A=sorted(list(map(int,input().split())))
L={}
for i in A:
if i not in L:
L[i]=1
else:
L[i]+=1
ans=[]
for j in range(A[0],A[-1]+1):
if j in L:
if j-1 in L:
if j+1 in L:
ans.append(L[j]+L[j+1]+L[j-1])
if len(A)>=3:
print(max(ans))
else:
... |
s071269757 | p03613 | u707870100 | 1565657033 | Python | Python (3.4.3) | py | Runtime Error | 137 | 14604 | 512 | # -*- coding: utf-8 -*-
#ARC082C
import copy
import sys
import math
n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
hoge.sort()
hoge.append(-1)
a=0
b=0
c=1
maxhoge=0
for i in range(0,n):
if(hoge[i]!=hoge[i+1]):
if(i!=n-1):
if(hoge[i+1]-hoge[i]==1):
a=b
b=c
c=1
elif(... |
s091183349 | p03613 | u992394626 | 1564020547 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 2036 | #include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ... |
s638997774 | p03613 | u856232850 | 1526102844 | Python | Python (3.4.3) | py | Runtime Error | 121 | 20704 | 202 | n = int(input())
a = list(map(int,input().split()))
b ={i:0 for i in range(min(a)-1,max(a)+10)}
for i in a:
b[i] += 1
c = 0
for i in range(1,len(b)-3):
c = max(c,b[i]+b[i+1]+b[i+2])
print(c) |
s974797579 | p03613 | u562016607 | 1517908191 | Python | Python (3.4.3) | py | Runtime Error | 123 | 15536 | 356 | N = int(input())
a = [0 for i in range(N)]
st = input().split()
for i in range(N):
a[i] = int(st[i])
m = min(a); M = max(a)
b = [0 for i in range(M - m + 1)]
for i in range(N):
b[a[i]-m] += 1
c = [0 for i in range(M - m + 1)]
c[0] = b[0] + b[1]
c[M - m] = b[M - m] + b[M - m - 1]
for i in range(1, M - m):
c[i] = b... |
s050676713 | p03613 | u855200003 | 1506911025 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 394 | rt numpy as np
N = int(input())
a = [int(i) for i in input().split(" ")]
a = np.array(a,dtype='int')
def count(a):
return [1 if i==1 or i== 0 or i == -1 else 0 for i in a]
if N == 1:
print(1)
else:
min_ = min(a)-1
max_ = max(a)+1
ans = -1
for K in range(min_,max_):
b = a - K
tmp ... |
s583352408 | p03613 | u306773664 | 1505790431 | Python | Python (3.4.3) | py | Runtime Error | 43 | 10152 | 171 | import sys
N = int(sys.stdin.readline())
data = [0] * 10000
for i in map(int,sys.stdin.readline().split()):
data[i] += 1
print(max(map(sum,zip(data,data[1:],data[2:]))))
|
s416571292 | p03613 | u832025497 | 1505104817 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 647 | # 23:30~0:30
import pandas as pd
import re
import statistics as st
import numpy as np
ELEM_MAX = 10**5
counter = np.zeros(ELEM_MAX+1)
def count(x):
counter[x] += 1
# 入力部
N = input()
a = input()
# 前処理部
# 文字列リストに変換
a = re.split(' ', a)
# intに変換
N = int(N)
a = list(map(int, a))
# Series->DataFrameに変換
a = pd.Ser... |
s028292888 | p03613 | u963682312 | 1504439906 | Python | Python (3.4.3) | py | Runtime Error | 86 | 13964 | 327 | if __name__ == '__main__':
N = int(input())
a = input()
a = a.split(' ')
a = list(map(int, a))
min_a = min(a)
max_a = max(a)
num = []
for i in range(max_a+1):
num.append(0)
for i in a:
num[i-2] += 1
num[i-1] += 1
num[i] += 1
c = max(num)
p... |
s894652015 | p03613 | u792078574 | 1504406463 | Python | Python (2.7.6) | py | Runtime Error | 13 | 3348 | 801 | X = int(raw_input())
K = int(raw_input())
rs = map(int, raw_input().split(" "))
Q = int(raw_input())
qs = []
for q in xrange(Q):
qs.append(map(int, raw_input().split(" ")))
memo = {}
l = len(qs)
for i in xrange(l):
t = 0
start = qs[i][1]
s = start
end = qs[i][0]
pre = 0
k = 0
if start in memo:
j ... |
s692135718 | p03613 | u325233786 | 1504405773 | Python | Python (2.7.6) | py | Runtime Error | 13 | 3348 | 762 | x=int(raw_input())
k=int(raw_input())
R=[int(i) for i in raw_input().split(' ')]
Q=int(raw_input())
RES=[]
for q in range(Q):
RES.append((int(i) for i in raw_input().split(' ')))
tintervals=[[0,R[0],R[0]]]
if k>1:
for ts in range(1,len(R)):
tintervals.append([R[ts-1],R[ts],R[ts]-R[ts-1]])
for t, a in RE... |
s464257440 | p03614 | u760771686 | 1600895201 | Python | PyPy3 (7.3.0) | py | Runtime Error | 105 | 86048 | 242 | N = int(input())
P = list(map(int,input().split()))
L = [False]*N
for i in range(N):
if P[i] == i+1:
L = True
ans = 0
for i in range(N):
if L[i]:
if i<N-1 and L[i+1]:
ans+1
i+=1
else:
ans+=1
print(ans)
|
s321351065 | p03614 | u696444274 | 1590961862 | Python | Python (3.4.3) | py | Runtime Error | 75 | 13880 | 229 | n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n):
if i+1 == p[i]:
tmp = p[i]
p[i] = p[i+1]
p[i+1] = tmp
count += 1
if p[-1] == n:
count += 1
print(count)
|
s849098943 | p03614 | u970082363 | 1583765822 | Python | Python (3.4.3) | py | Runtime Error | 96 | 13880 | 388 | n = int(input())
p = [int(i) for i in input().split()]
ox = []
ans = 0
j = 0
for i in range(n):
if p[i]==i+1:
ox.append("x")
else:
ox.append("o")
while j!=n-1:
if ox[j]=="x":
ans += 1
c = p[j]
p[j] = p[j+1]
p[j+1] = c
j += 1
j += 1
if ox[n-1]=... |
s078772665 | p03614 | u623819879 | 1579231264 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38256 | 127 | n=int(input())
a=[int(i) for i in input().split()]
r=0
t=0
while t<n:
if a[t]==t+1:
r+=1
t+=1+r
print(r)
|
s125031530 | p03614 | u346308892 | 1576547258 | Python | Python (3.4.3) | py | Runtime Error | 82 | 14004 | 319 | def acinput():
return list(map(int,input().split(" ")))
N=int(input())
s=acinput()
s.insert(0,0)
dp=[0]*(N+1)
#dp[0]=int(1==s[0])
for i in range(1,N+1):
if s[i]==i:
dp[i]=dp[i-1]+1
try:
s[i+1]=s[i]
except e:
pass
else:
dp[i]=dp[i-1]
print(dp[-1])
|
s245659730 | p03614 | u346308892 | 1576547082 | Python | Python (3.4.3) | py | Runtime Error | 78 | 14008 | 266 | def acinput():
return list(map(int,input().split(" ")))
N=int(input())
s=acinput()
s.insert(0,0)
dp=[0]*(N+1)
#dp[0]=int(1==s[0])
for i in range(1,N+1):
if s[i]==i:
dp[i]=dp[i-1]+1
s[i+1]=s[i]
else:
dp[i]=dp[i-1]
print(dp[-1]) |
s895503502 | p03614 | u761529120 | 1572572029 | Python | PyPy3 (2.4.0) | py | Runtime Error | 222 | 53036 | 375 | def main():
N = int(input())
P = list(map(int, input().split()))
cnt = 0
i = 0
while i < N:
if i + 1 == P[i]:
if i + 2 == P[i+1]:
cnt += 1
i += 2
else:
cnt += 1
i += 1
else:
i += 1... |
s312818838 | p03614 | u298297089 | 1567635155 | Python | Python (3.4.3) | py | Runtime Error | 67 | 10420 | 123 | n = int(input())
ans = 0
for i,p in enumerate(map(int,input().split())):
if i + 1 == p:
ans += 1
print(max(ans-1), 0) |
s460304395 | p03614 | u930970950 | 1562377979 | Python | Python (3.4.3) | py | Runtime Error | 81 | 10680 | 189 | n = int(input())
l = [int(i + 1 == e) for i, e in enumerate(map(int, input().split()))]
res = 0
for i in range(n):
if l[i]:
if l[i + 1]: l[i + 1] = 0
res += 1
print(res) |
s702500688 | p03614 | u513900925 | 1559762317 | Python | Python (3.4.3) | py | Runtime Error | 79 | 13880 | 195 | N=int(input())
p = list(int(i) for i in input().split())
count = 0
for i in range(N):
if p[i] == i+1:
a = p[i]
p[i] = p[i+1]
p[i+1] = a
count += 1
print(count) |
s322940003 | p03614 | u572144347 | 1551234242 | Python | PyPy3 (2.4.0) | py | Runtime Error | 226 | 52844 | 850 | N = int(input())
P = list(map(int, input().split()))
lst = []
ans = 0
skip = False
for e,p in enumerate(P,1):
if skip:
skip = False
continue
if e == p:
ans += 1
if e-1 < N and P[e] == e+1:
skip = True
# lst.append(e)
print(ans)
exit(0)
st = False
ans = 0
for... |
s346060603 | p03614 | u375616706 | 1550108012 | Python | Python (3.4.3) | py | Runtime Error | 68 | 13876 | 309 | # python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
seq = 0
ans = 0
for i in range(1, N+1):
if A[i] == i:
seq += 1
else:
ans += (seq+1)//2
seq = 0
ans += (seq+1)//2
print(ans)
|
s780932209 | p03614 | u690536347 | 1535545673 | Python | Python (3.4.3) | py | Runtime Error | 69 | 14008 | 186 | n=int(input())
*l,=map(int,input().split())
v=0
for i in range(n-1):
if l[i]==i+1:
l[i],l[i+1]=l[i+1],l[i]
v+=1
if l[N-1]==N:
l[N-2],l[N-1]=l[N-1],l[N-2]
v+=1
print(v) |
s069214111 | p03614 | u029169777 | 1530038096 | Python | Python (3.4.3) | py | Runtime Error | 87 | 13880 | 240 | N=int(input())
A=list(map(int,input().split()))
answer=0
for i in range(N):
if A[i]==i+1:
if A[i+1]!=i+1 and i!=N-1:
A[i],A[i+1]=A[i+1],A[i]
answer+=1
else:
A[i],A[i-1]=A[i-1],A[i]
answer+=1
print(answer) |
s450445184 | p03614 | u026788530 | 1529081028 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 122 | N = int(input())
p = input().split(' ')
ans = 1
for i in range(N):
if int(p[i])==i):
ans += 1
print(ans//2)
|
s142442323 | p03614 | u425448230 | 1509513670 | Python | Python (3.4.3) | py | Runtime Error | 72 | 14008 | 170 | N = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(N):
if p[i] == i+1:
p[i], p[i+1] = p[i+1], p[i]
count += 1
print(count) |
s719718236 | p03614 | u902644648 | 1506981558 | Python | Python (3.4.3) | py | Runtime Error | 78 | 13880 | 151 | N = int(input())
p = [int(p_i) for p_i in input().split()]
answer = 0
for i in range(N):
if p[i] == i+1:
answer += 1
p[i+1] = p[i]
print(answer) |
s748432656 | p03614 | u612721349 | 1504404908 | Python | PyPy3 (2.4.0) | py | Runtime Error | 218 | 53484 | 401 | def solve():
n = int(input())
al = [int(i) for i in input().split()]
memos = [0]*n
for i in range(n):
memos[i] = i - (al[i] - 1)
# print(memos)
ans = 0
for idx in range(n):
if memos[idx] == 0:
memos[idx+1], memos[idx] = memos[idx+1]-1, memos[idx]+1
ans... |
s053543162 | p03614 | u612721349 | 1504403569 | Python | PyPy3 (2.4.0) | py | Runtime Error | 215 | 53484 | 775 | def solve():
n = int(input())
al = [int(i) for i in input().split()]
memos = [0]*n
for i in range(n):
memos[i] = i - (al[i] - 1)
# print(memos)
ans = 0
for idx in range(n):
while memos[idx] == 0:
if idx == 0:
memos[idx], memos[idx+1] = memos[idx+1]... |
s459833194 | p03614 | u612721349 | 1504403413 | Python | PyPy3 (2.4.0) | py | Runtime Error | 210 | 53484 | 670 | def solve():
n = int(input())
al = [int(i) for i in input().split()]
memos = [0]*n
for i in range(n):
memos[i] = i - (al[i] - 1)
# print(memos)
ans = 0
for idx in range(n):
if memos[idx] == 0:
if idx == 0:
memos[idx], memos[idx+1] = memos[idx+1]-1,... |
s427360866 | p03614 | u653807637 | 1504401785 | Python | Python (3.4.3) | py | Runtime Error | 57 | 13880 | 259 | # encoding:utf-8
def main():
n = int(input())
nums = list(map(int, input().split()))
counter = 0
for i in range(n):
if nums[i] == i + 1:
nums[i], nums[i + 1] = nums[i + 1], nums[i]
counter += 1
print(counter)
if __name__ == '__main__':
main() |
s300815550 | p03615 | u274555984 | 1507932492 | Python | Python (3.4.3) | py | Runtime Error | 2107 | 60000 | 5102 | import math
import itertools
def read_data():
try:
LOCAL_FLAG
import codecs
import os
lines = []
file_path = os.path.join(os.path.dirname(__file__), 'arc082-e.dat')
with codecs.open(file_path, 'r', 'utf-8') as f:
lines.append(f.readline().rstrip("\r\n"))... |
s543889517 | p03615 | u340781749 | 1504828606 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 656 | from collections import Counter
from math import gcd
n = int(input())
xys = [tuple(map(int, input().split())) for _ in range(n)]
MOD = 998244353
excludes = 0
for i, (x1, y1) in enumerate(xys):
slopes = []
for x2, y2 in xys[i + 1:]:
dx, dy = x2 - x1, y2 - y1
if dx == 0:
slopes.appen... |
s589195155 | p03615 | u985443069 | 1504417824 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 18 | 4
0 0
0 1
1 0
1 1
|
s141854485 | p03615 | u104282757 | 1504411996 | Python | Python (3.4.3) | py | Runtime Error | 48 | 3436 | 710 | # E
from collections import Counter
N = int(input())
xy_list = [list(map(int, input().split())) for _ in range(N)]
M = 998244353
res = pow(2, N, M)
# 0 points
res -= 1
# 1 points
res -= N
# all lines
line_cnt = [0]*(N+1)
for i in range(N):
xi, yi = xy_list[i]
angle_list = []
for j in range(N):
... |
s248416991 | p03616 | u754022296 | 1591457981 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2696 | 885 | import sys
input = sys.stdin.readline
x = int(input())
k = int(input())
R = [(_r, i%2) for i, _r in enumerate(map(int, input().split()))]
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]
T, A = zip(*TA)
L = [None]*n
b = 0
for i, t in enumerate(T, 1):
R.append((t, -i))
R.sort()
dx = 1
l, r, p... |
s383905881 | p03616 | u419645731 | 1546227955 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1326 | input = __import__('sys').stdin.readline
MIS = lambda: map(int,input().split())
# f(a) = z a <= x1
# a+z-x1 x1 <= a <= x2
# x2+z-x1 x2 <= a
class Sandgraph:
def __init__(_, X):
_.z = _.x1 = 0
_.x2 = X
def __repr__(_):
return f"<{_.z} {_.x1} {_... |
s183442738 | p03616 | u274555984 | 1509061437 | Python | Python (3.4.3) | py | Runtime Error | 589 | 25968 | 2517 | def read_data_f(filename='arc082-e.dat'):
try:
LOCAL_FLAG
import codecs
import os
lines = []
file_path = os.path.join(os.path.dirname(__file__), filename)
with codecs.open(file_path, 'r', 'utf-8') as f:
for each in f:
lines.append(each.rst... |
s968000328 | p03616 | u792078574 | 1504406479 | Python | Python (2.7.6) | py | Runtime Error | 2123 | 315836 | 801 | X = int(raw_input())
K = int(raw_input())
rs = map(int, raw_input().split(" "))
Q = int(raw_input())
qs = []
for q in xrange(Q):
qs.append(map(int, raw_input().split(" ")))
memo = {}
l = len(qs)
for i in xrange(l):
t = 0
start = qs[i][1]
s = start
end = qs[i][0]
pre = 0
k = 0
if start in memo:
j ... |
s263217129 | p03616 | u792078574 | 1504406096 | Python | Python (2.7.6) | py | Runtime Error | 2124 | 331620 | 787 | X = int(raw_input())
K = int(raw_input())
rs = map(int, raw_input().split(" "))
Q = int(raw_input())
qs = []
for q in xrange(Q):
qs.append(map(int, raw_input().split(" ")))
memo = {}
l = len(qs)
for i in xrange(l):
t = 0
start = qs[i][1]
s = start
end = qs[i][0]
pre = 0
k = 0
if start in memo:
j ... |
s003919337 | p03616 | u243492642 | 1504405351 | Python | PyPy3 (2.4.0) | py | Runtime Error | 969 | 100120 | 1471 | # coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def read():
X = II()
K = II()
r = ILI()
Q = II()
queries = [ILI() for __ in range(Q)]
return X, K, r, Q, queries
def solve(X, K, r, Q, queries):
l_ans = []
r.insert(0, 0)
dif_r = [r[i ... |
s520998752 | p03617 | u306412379 | 1599058706 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9028 | 214 | Q, H, S, D = map(int, input().split())
N = int(input())
arr = [4*Q*N, 2*H*N, S*N]
if N % 2 == 0:
arr.append(int(0.5*D*N))
elif:
if N >= 3:
arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
print(min(arr)) |
s797639223 | p03617 | u411923565 | 1598319905 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9140 | 209 | #A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())
Q1,H1 = 4*Q,2*H
S = min(Q1,H1,S)
if 2*S>D:
cnt_2 = N//2
cnt_1 = N%2
pay = a*cnt_2 + S*cnt_1
else:
pay = N * S
print(pay) |
s546580104 | p03617 | u411923565 | 1598319872 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9184 | 214 | #A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())
Q1,H1 = 4*Q,2*H
S = min(Q1,H1,S)
if 2*S>D:
cnt_2 = N//2
cnt_1 = N%2
pay = a*cnt_2 + S*cnt_1
else:
pay = N * S
print(int(pay)) |
s778568700 | p03617 | u411923565 | 1598319841 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9140 | 219 | #A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())
Q1,H1 = 4*Q,2*H
S = min(Q1,H1,S)
if 2*S>D:
cnt_2 = N//2
cnt_1 = N%2
pay = a*cnt_2 + S*cnt_1
else:
pay = (N//A) * S
print(int(pay)) |
s764668274 | p03617 | u411923565 | 1598319766 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9104 | 252 | #A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())
#2Lあたり
Q1,H1 = 4*Q,2*H
S = min(Q1,H1,S)
if 2*S>D:
cnt_A = N//2
cnt_B = N%2
pay = a*cnt_A + (cnt_B/B)*(b/(2/B))
else:
pay = (N//A) * (a/(2/A))
print(int(pay)) |
s358724812 | p03617 | u411923565 | 1598319715 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9148 | 260 | #A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())
#2Lあたり
Q1,H1,S1 = 8*Q,4*H,2*S
S = min(Q1,H1,S1)
if 2*S>D:
cnt_A = N//2
cnt_B = N%2
pay = a*cnt_A + (cnt_B/B)*(b/(2/B))
else:
pay = (N//A) * (a/(2/A))
print(int(pay)) |
s069922981 | p03617 | u411923565 | 1598319662 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9132 | 261 | #A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())
#2Lあたり
Q1,H1,S1 = 8*Q,4*H,2*S
S = min(Q1,H1,S1)
if 2*S>D:
cnt_A = N//2
cnt_B = N%2
pay = a*cnt_A + (cnt_B/B)*(b/(2/B))
else:
pay = (N//A) * (a/(2/A))
print(int(pay)) |
s202653837 | p03617 | u201928947 | 1597302308 | Python | PyPy3 (7.3.0) | py | Runtime Error | 101 | 74644 | 92 | Q,H,S,D = map(int,input().split())
X = min(4*Q,2*H,S)
Y = min(2*X,D)
print((N//2)*Y+(N%2)*X) |
s518634985 | p03617 | u430928274 | 1594992434 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8928 | 595 | q, h, s, d = map(int, input().split())
n = int(input())
ans = 0
q_per = q / 0.25
h_per = h / 0.5
s_per = s
d_per = d / 2
list = [q_per,h_per,s_per,d_per]
elif min(list) == d_per :
if n%2 == 0:
ans += d * (n //2)
else :
ans += n//2 * d
n -= n//2
list.remove(d_per)
if min(l... |
s854780827 | p03617 | u163421511 | 1594876272 | Python | Python (3.8.2) | py | Runtime Error | 28 | 8856 | 130 | q, h, s, d = map(int, input().split())
n = int(input())
ans = n//2*min(8*q, 4*h, 2*s, d) + min(4*q, 2*h, s)*(n%2!==0)
print(ans)
|
s639590178 | p03617 | u616489782 | 1593720559 | Python | Python (3.8.2) | py | Runtime Error | 29 | 8952 | 336 | price = [int(x) for x in input().split()];
N = int(input());
price_d = price[3];
price_s = 2*price[2];
price_h = 4*price[1];
price_q = 8*price[0];
p = min([price_q,price_h,price_s]);
if price_d < p :
if N%2 == 1 :
ans = (N-1)//2*price_d + p//2;
else :
ans = N//2*price_d;
else :
ans = N*p//2;... |
s220609009 | p03617 | u547537397 | 1593491178 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9148 | 118 | q,h,re,d = map(int,input().split())
n = int(input())
re = min(q*4, h*2,result)
print(min(result*n, n//2*d + (n%2)*re)) |
s242171494 | p03617 | u277429554 | 1593410187 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9044 | 160 | a, b, c, d = map(int, input().split())
n = int(input())
b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)
q, r = divmod(N, 2)
x = q * d + r * c
print(x) |
s458984606 | p03617 | u493130708 | 1591605664 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38384 | 3512 | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
#############
# Constants #
#####... |
s927269156 | p03617 | u961683878 | 1591596549 | Python | Python (3.4.3) | py | Runtime Error | 2117 | 1762280 | 471 | #! /usr/bin/env python3
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
Q, H, S, D, N = map(int, read().split())
dp = [1<<60] * (N + 2)
dp[0] = 0
for i in range(1, N+1):
... |
s729163787 | p03617 | u023229441 | 1590668358 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38384 | 649 | q,h,s,d=map(int,input().split())
n=int(input())
n*=4
if q*2<h:
if h*2<s:
if q*8<d:
print(n*q);exit()
else:
print(q*(n%8)+d*(n//8));exit()
elif 2*s<d:
if q*4<s:
print(n*q)
else:
print(s*(n//4));exit()
else:
if q*4<s:
print(d*(n... |
s213086603 | p03617 | u156815136 | 1590666229 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 110 | q,h,s,d = map(int,input().split())
N = int(input())
one = min(q*4,h*2,s)
print(min(one*N,d*(N//2)+one*(n%2)))
|
s326374238 | p03617 | u652656291 | 1589551109 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 157 | q,h,s,d = map(int,input().split())
n = int(input())
a = min(q*4,h*2,s)
if n % 2 == 0:
print(min(n/(a*2),n/d))
else:
print(min(n/(a*2)+d),n/d)
|
s826713005 | p03617 | u225084815 | 1588975280 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38384 | 487 | import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
q, h, s, d = map... |
s954167282 | p03617 | u353919145 | 1587158558 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 220 | a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, 4*a+2*b)
if n%2==0 :
print(twoltr*n//2)
else :
print(oneltr+twoltr*(n-1)//2)
|
s804971013 | p03617 | u816631826 | 1587158425 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 256 | a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)
if n%2==0 :
print(twoltr * (n//2))
else :
print(oneltr+twoltr * ((n-1)//2))
|
s476752137 | p03617 | u018679195 | 1587158306 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 248 | a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)
if n%2==0 :
print(twoltr*n//2)
else :
print(oneltr+twoltr*(n-1)//2)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.