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
s598897031
p03715
u941753895
1579227256
Python
Python (3.4.3)
py
Runtime Error
42
5556
1131
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): ...
s745978389
p03715
u814986259
1574790731
Python
Python (3.4.3)
py
Runtime Error
17
2940
1148
import math H,W=map(int,input().split()) if H%3==0 or W%3==0: print(0) exit(0) S=[0]*3 s=H*import math H,W=map(int,input().split()) if H%3==0 or W%3==0: print(0) exit(0) S=[0]*3 s=H*W/3 w0=math.ceil(s/H) h0=math.ceil(s/W) S[0]=w0*H w1=W-W/3 w0=math.ceil(s/H) h0=math.ceil(s/W) S[0]=w0*H w1=W-w0 if w1%2==0 or H...
s472310363
p03715
u691896522
1574557419
Python
PyPy3 (2.4.0)
py
Runtime Error
203
40924
264
h, w = map(int, input().split()) if h % 3 == 0 or w % 3 == 0: print(0) else: middle = w // 2 ans = 10 ** 10 for i in range(h): area = [i * w, (h - i) * middle, (h - i) * (w - middle)] ans = min(ans, max(area) - min(area)) print(ans)
s745263130
p03715
u557494880
1573457469
Python
Python (3.4.3)
py
Runtime Error
17
3064
543
N = int(input()) A = list(map(int,input().split())) S = [] P = A[:N] Q = A[2*N:] for i in range(N): Q[i] *= -1 R = A[N:2*N] p = [0]*(N+1) q = [0]*(N+1) import heapq heapq.heapify(P) heapq.heapify(Q) sp = sum(P) sq = sum(Q) p[0] = sp q[0] = sq for i in range(1,N+1): heapq.heappush(P,R[i-1]) x = heapq.heappo...
s281054744
p03715
u557494880
1573456945
Python
Python (3.4.3)
py
Runtime Error
17
3064
546
N = int(input()) A = list(map(int,input().split())) S = [] P = A[:N] Q = A[2*N:] for i in range(N): Q[i] *= -1 R = A[N:2*N] p = [0]*(N+1) q = [0]*(N+1) import heapq heapq.heapify(P) heapq.heapify(Q) sp = sum(P) sq = sum(Q) p[0] = sp q[0] = sq for i in range(1,N+1): heapq.heappush(P,R[i-1]) heapq.heappop(P)...
s547675327
p03715
u557494880
1573455207
Python
PyPy3 (2.4.0)
py
Runtime Error
180
38384
418
N = int(input()) A = list(map(int,input().split())) S = [] import heapq for i in range(N+1): P = A[:(N+i)] Q = A[(N+i):] for l in range(len(Q)): Q[l] *= -1 heapq.heapify(P) heapq.heapify(Q) j = 0 k = 0 while j < i: heapq.heappop(P) j += 1 while k < N-i: ...
s189154162
p03715
u413165887
1569475103
Python
Python (3.4.3)
py
Runtime Error
518
18992
639
from math import floor, ceil h, w = map(int, input().split(' ')) result = [] if h%3 == 0 or w%3 == 0: print(0) else: for i in range(1, h-1): x = i*w y = (h-i)*floor(w/2) z = (h-i)*ceil(w/2) result.append(max(x,y,z)-min(x,y,z)) y = floor((h-i)/2)*w z = ceil((h-i)/2...
s511166275
p03715
u414425367
1557437783
Python
Python (3.4.3)
py
Runtime Error
148
12448
589
import numpy as np from heapq import heapreplace, heapify N=int(input()) A=np.array([int(a) for a in input().split(" ")]) lheap, rheap = list(A[:N]), list(-A[2*N:]) heapify(lheap) heapify(rheap) Lsum, Rsum = sum(lheap), sum(rheap) left = [Lsum] right = [Rsum] for i in range(N): if A[N+i] > lheap[0]: Lsum +...
s112914809
p03715
u367130284
1557131528
Python
Python (3.4.3)
py
Runtime Error
25
3444
476
from heapq import* from collections import* n,*a=map(int,open(0).read().split()) ans=-float("inf") b=a[:n] c=deque(a[n:]) heapify(b) s=sum(b) s2=sum(nsmallest(n,c)) red=[s-s2] for i in range(n,n*2): s+=a[i]-heappushpop(b,a[i]) c.popleft() s2=sum(nsmallest(n,c)) red+=[s-s2] print(max(red)) #あhjfkぁdshflk...
s003652229
p03715
u969190727
1557107910
Python
Python (3.4.3)
py
Runtime Error
227
3064
280
h,w=map(int,input().split()) if h*w%3==0: print(0) else: ans=min(h,w) hh=h//2 for ww in range(1,w): A=[hh*ww,(h-hh)*ww,h*(w-ww)] ans=min(ans,max(A)-min(A)) ww=w//2 for hh in range(1,h): B=[ww*hh,(w-ww)*hh,(h-hh)*w] ans=min(ans,max(B)-min(B)) print(ans)
s223390467
p03715
u911446944
1556946491
Python
Python (3.4.3)
py
Runtime Error
17
3060
227
n = int(input()) array = [int(i) for i in input().split()] ans=-1e14 for i in range(n, 2*n+1): l_array = sorted(array[:i]) r_array = sorted(array[i:]) ans = max(ans, sum(l_array[i-n:])-sum(r_array[:n])) print(ans)
s758072206
p03715
u722189950
1556901435
Python
Python (3.4.3)
py
Runtime Error
17
3064
564
#ABC074C H,W = map(int, input().split()) if H%3==0 or W%3==0: print(0) else: a=H//3 b=H//3+1 c=H-(a+b) abc=[a,b,c] ans=min(max(abc)-min(abc),ans) a=W//3 b=W//3+1 c=W-(a+b) abc=[a,b,c] ans=min(max(abc)-min(abc),ans) for i in range(1,W+1): a=i*H b=(W-i)*(H/...
s323040010
p03715
u091051505
1556553576
Python
Python (3.4.3)
py
Runtime Error
317
11060
596
h, w = map(int, input().split()) s = h * w if (h == 2) & (w == 2): ans = 1 if s % 3 == 0: ans = 0 else: c = [] for i in range(1, h-1): sa = i * w sb = (h - i) * (w // 2) sc = (h - i) * (w - (w // 2)) min_s = min(sa, min(sb, sc)) max_s = max(sa, max(sb, sc)) ...
s798695817
p03715
u091051505
1556553478
Python
Python (3.4.3)
py
Runtime Error
311
11060
560
h, w = map(int, input().split()) s = h * w if s % 3 == 0: ans = 0 else: c = [] for i in range(1, h-1): sa = i * w sb = (h - i) * (w // 2) sc = (h - i) * (w - (w // 2)) min_s = min(sa, min(sb, sc)) max_s = max(sa, max(sb, sc)) c.append(max_s - min_s) for i ...
s553340395
p03715
u923279197
1553893823
Python
PyPy3 (2.4.0)
py
Runtime Error
185
40176
502
h, w = map(int,input().split()) if h%3 ==0 or w % 3 == 0: print(0) exit() x = w//4 Sb =max(x*h,h//2*(w-x),(h-h//2)*(w-x)) Ss =min(x*h,h//2*(w-x),(h-h//2)*(w-x)) ans1 =Sb-ss x += 1 Sb =max(x*h,h//2*(w-x),(h-h//2)*(w-x)) Ss =min(x*h,h//2*(w-x),(h-h//2)*(w-x)) ans2 =Sb-ss y = h//4 Sb =max(y*w,w//2*(h-y),(w-w//2)*(h-y)...
s285051053
p03715
u192903163
1544851451
Python
Python (3.4.3)
py
Runtime Error
18
3064
179
import sys a,b=map(int,input().split()) if a>b: swap(a,b) if a%3==0 or b%3==0: print(0) sys.exit() c=int((b+1)/3) b-=c d=int(a/2) e=a-d print(max(c*a,b*d,b*e)-min(c*a,b*d,b*e))
s775422708
p03715
u192903163
1544851336
Python
Python (3.4.3)
py
Runtime Error
19
3064
165
a,b=map(int,input().split()) if a>b: swap(a,b) if a%3==0 or b%3==0: print(0) exit(0) c=int((b+1)/3) b-=c d=int(a/2) e=a-d print(max(c*a,b*d,b*e)-min(c*a,b*d,b*e))
s618824726
p03715
u846150137
1530478158
Python
Python (3.4.3)
py
Runtime Error
179
3064
436
h, w=map(int,input().split()) m = h * w if h % 3 == 0 or w % 3 == 0: print(0) exit() def chk(h,w): a = m for i in range(1, h): l = i * w o = (h - i) // 2 * w g = m - l - o a = min(a, max(abs(l - o), abs(g - o), abs(g - l))) for i in range(1, h): l = i * w o = (h - i) * (w // 2) ...
s797649923
p03715
u218843509
1525736572
Python
Python (3.4.3)
py
Runtime Error
17
3064
508
h, w = map(int, input().split()) l = max(h, w) s = min(h, w) if h % 3 == 0 or w % 3 == 0: print(0) else: if abs((l // 3) - l / 3) <= abs((l // 3 + 1) - l / 3): block1 = s * (l // 3) block3 = (l - (l // 3)) * ((s + 1) // 2) block2 = H * W - block1 - block3 print(max(block1, block2, block3) - min(block1, block2...
s766594323
p03715
u243492642
1495379656
Python
Python (3.4.3)
py
Runtime Error
59
5236
1263
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI():...
s565467165
p03715
u405779580
1495379430
Python
Python (3.4.3)
py
Runtime Error
202
3064
545
h, w = map(int, input().split()) def calculate_t(x, y): min_d = 1e12 for i in range(x): s1 = (y//2)*i s2 = y*(x-i) s3 = (y-y//2)*i min_d = min(min_d, max(s1,s2,s3) - min(s1,s2,s3)) return min_d def calculate_3(x, y): for i in range(x): w1 = i w2 = (x-i)//2...
s880684545
p03715
u405779580
1495342494
Python
Python (3.4.3)
py
Runtime Error
44
3064
769
h, w = map(int, input().split()) if h%3 == 0 or w%3 ==0: print(0) else: def calculate_t(x, y): d = h*w + 1 i = x//2 s1, s2 = 0, d rng = range(x) if x < 1000 else range(x//3, x*4//5) new_d = h*w for i in rng: s1 = (y//2)*i s2 = y*(x-i) ...
s057159441
p03715
u405779580
1495337348
Python
Python (3.4.3)
py
Runtime Error
17
3060
570
h, w = map(int, input().split()) if h%3 == 0 or w%3 ==0: print(0) else: def calculate_d(x, y): d = h*w + 1 i = x//2 s1, s2 = 0, d for i in range(x): s1 = (y//2)*i s2 = y*(x-i) s3 = (y-y//2)*i new_d = max(abs(s1-s2), abs(s1-s3)) ...
s574667340
p03715
u810735437
1495336996
Python
Python (3.4.3)
py
Runtime Error
17
2940
582
def max_minus_min(areas): # print("areas", areas) return max(areas) - min(areas) def solve2(h, w): area1 = h * (w // 2) area2 = h * w - area1 return [area1, area2] def solve(h, w): w_div_3 = w // 3; ans = 1e9 for w2 in range(w_div_3, w_div_3 + 2): area1 = w2 * h tmp ...
s291572958
p03715
u810735437
1495336693
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38256
524
def max_minus_min(areas): # print("areas", areas) return max(areas) - min(areas) def solve2(h, w): area1 = h * (w // 2) area2 = h * w - area1 return area1, area2 def solve(h, w): w_div_3 = w // 3; ans = 1e9 for w2 in range(w_div_3, w_div_3 + 2): area1 = w2 * h ans = m...
s991200741
p03715
u810735437
1495336353
Python
Python (3.4.3)
py
Runtime Error
17
3064
526
def max_minus_min(areas): # print("areas", areas) return max(areas) - min(areas) def solve2(h, w): area1 = h * (w // 2) area2 = h * w - area1 return [area1, area2] def solve(h, w): w_div_3 = w // 3; ans = 1e9 for w2 in range(w_div_3, w_div_3 + 2): area1 = w2 * h ans =...
s849111502
p03715
u810735437
1495336205
Python
Python (3.4.3)
py
Runtime Error
17
3060
633
def max_minus_min(areas): # print("areas", areas) # return max(areas) - min(areas) return 999 def solve2(h, w): return 7, 7 # area1 = h * (w // 2) # area2 = h * w - area1 # return area1, area2 def solve(h, w): w_div_3 = w // 3; ans = 1e9 for w2 in range(w_div_3, w_div_3 + 2):...
s918925825
p03715
u810735437
1495336065
Python
Python (3.4.3)
py
Runtime Error
18
3060
563
def max_minus_min(areas): # print("areas", areas) # return max(areas) - min(areas) return 999 def solve2(h, w): return 7, 7 # area1 = h * (w // 2) # area2 = h * w - area1 # return area1, area2 def solve(h, w): w_div_3 = w // 3; ans = 1e9 for w2 in range(w_div_3, w_div_3 + 2):...
s207943562
p03715
u810735437
1495336023
Python
Python (3.4.3)
py
Runtime Error
18
3064
546
def max_minus_min(areas): # print("areas", areas) return max(areas) - min(areas) def solve2(h, w): return 7, 7 # area1 = h * (w // 2) # area2 = h * w - area1 # return area1, area2 def solve(h, w): w_div_3 = w // 3; ans = 1e9 for w2 in range(w_div_3, w_div_3 + 2): area1 = ...
s287592720
p03715
u810735437
1495335975
Python
Python (3.4.3)
py
Runtime Error
17
3064
524
def max_minus_min(areas): # print("areas", areas) return max(areas) - min(areas) def solve2(h, w): area1 = h * (w // 2) area2 = h * w - area1 return area1, area2 def solve(h, w): w_div_3 = w // 3; ans = 1e9 for w2 in range(w_div_3, w_div_3 + 2): area1 = w2 * h ans = m...
s121262221
p03715
u608297208
1495334975
Python
PyPy3 (2.4.0)
py
Runtime Error
202
38640
270
n = int(input()) A = list(map(int,input().split())) B = [] for i in range(n,2*n + 1): A1 = A[:i] A2 = A[i:] a1 = i - n a2 = 2 * n - i A1.sort() A1 = A1[a1:] A2.sort() if a2 != 0: A2 = A2[:-a2] #print(A1,A2) B.append(sum(A1) - sum(A2)) #print(B) print(max(B))
s123512118
p03715
u810735437
1495334606
Python
Python (3.4.3)
py
Runtime Error
17
3064
523
def max_minus_min(areas): # print("areas", areas) return max(areas) - min(areas) def solve2(h, w): area1 = h * (w // 2) area2 = h * w - area1 return area1, area2 def solve(h, w): w_div_3 = w // 3; ans = 1e9 for w2 in range(w_div_3, w_div_3 + 2): area1 = w2 * h ans = m...
s857239244
p03715
u894844146
1495334218
Python
Python (3.4.3)
py
Runtime Error
17
2940
1221
#include <iostream> #include <vector> #include <climits> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> using std::vector; using std::cin; using std::cout; using std::endl; using std::memset; using std::memset; using std::floor; using std::abs; using std::min; using std::max; int main() { ...
s549188152
p03715
u810735437
1495329216
Python
Python (3.4.3)
py
Runtime Error
18
3064
721
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array from bisect import * from collections import * import fractions import heapq from itertools import * import math import re import string def max_minus_min(areas): # print("areas", areas) return max(areas) - min(areas) def solve2(h, w): area1 = ...
s985480546
p03715
u810735437
1495329121
Python
Python (3.4.3)
py
Runtime Error
17
3064
721
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array from bisect import * from collections import * import fractions import heapq from itertools import * import math import re import string def max_minus_min(areas): # print("areas", areas) return max(areas) - min(areas) def solve2(h, w): area1 = ...
s331084925
p03716
u139112865
1594070924
Python
Python (3.8.2)
py
Runtime Error
356
43852
709
import heapq n = int(input()) a = list(map(int, input().split())) l = a[:n] heapq.heapify(l) memo_l = [0 for _ in range(n+1)] memo_l[0] = sum(a[:n]) for i in range(1, n+1): memo_l[i] = memo_l[i-1] if l[0] < a[n+i-1]: x = heapq.heappop(l) heapq.heappush(l, a[n+i-1]) memo_l[i] += a[n+i-1...
s262068043
p03716
u644907318
1593916781
Python
PyPy3 (7.3.0)
py
Runtime Error
475
130924
788
import heapq N = int(input()) A = list(map(int,input().split())) B1 = [] for i in range(N): heapq.heappush(B1,(A[i],i)) C = [] for i in range(N,3*N): heapq.heappush(C,(A[i],i)) B2 = [] for _ in range(N): a,i = heapq.heappop(C) B2.append((-a,i)) dmax = 0 for i in range(N): dmax += B1[i][0]+B2[i][0] C...
s040391828
p03716
u644907318
1593916675
Python
PyPy3 (7.3.0)
py
Runtime Error
435
129520
781
import heapq N = int(input()) A = list(map(int,input().split())) B1 = [] for i in range(N): heapq.heappush(B1,(A[i],i)) C = [] for i in range(N,3*N): heapq.heappush(C,(A[i],i)) B2 = [] for _ in range(N): a,i = heapq.heappop(C) B2.append((-a,i)) dmax = 0 for i in range(N): dmax += B1[i][0]+B2[i][0] C...
s499711374
p03716
u072717685
1592086714
Python
Python (3.4.3)
py
Runtime Error
2105
39636
1190
from heapq import heapify, heappop from copy import deepcopy def main(): n = int(input()) a = list(map(int, input().split())) a_mae = deepcopy(a[:n * 2]) a_ushiro = deepcopy(a[n:]) a_ushiro = [i * -1 for i in a_ushiro] #print(a_mae, a_ushiro) a_ave = sum(a_mae) / (n * 2) ar_ave = sum(a...
s362292592
p03716
u207097826
1588543426
Python
Python (3.4.3)
py
Runtime Error
93
37084
549
N = int(input()) a = list(map(int, input().split())) A = (a[0:N]) A = deque(sorted(A)) B = deque(a[N:2*N]) C = a[2*N:3*N] C = deque(sorted(C, reverse = True)) original_score = 0 for i in range(N): original_score += A[i] - C[i] left = 0 right = 0 for i in range(N): left_candidate = B[left] - A[left] ri...
s224351142
p03716
u691018832
1588124314
Python
Python (3.4.3)
py
Runtime Error
2104
152600
894
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from heapq import heapify, heappop, heappush from collections import deque from copy import deepcopy n, *a = map(int, read().split()) p = a[:n] m = list(map(lambda x: int...
s304238496
p03716
u041351774
1587937514
Python
PyPy3 (2.4.0)
py
Runtime Error
476
122512
394
import heapq n=int(input()) a=list(map(int,input().split())) q=a[0:n] heapq.heapify(q) p=list(map(lambda x: x*(-1),a[2*n:3*n])) heapq.heapify(p) sums=sum(q)+[0]*(n-1)+sum(p) am=a[n:2*n] for i in range(0,n): heapq.heappush(q,am[i]) heapq.heappop(q) sums[i+1]=sum(q) for i in range(n-1,-1,-1): heapq.heappu...
s215215478
p03716
u041351774
1587937490
Python
PyPy3 (2.4.0)
py
Runtime Error
470
122512
394
import heapq n=int(input()) a=list(map(int,input().split())) q=a[0:n] heapq.heapify(q) p=list(map(lambda x: x*(-1),a[2*n:3*n])) heapq.heapify(p) sums=sum(q)+[0]*(n-1)+sum(p) am=a[n:2*n] for i in range(0,n): heapq.heappush(q,am[i]) heapq.heappop(q) sums[i+1]=sum(q) for i in range(n-1,-1,-1): heapq.heappu...
s012984509
p03716
u191394596
1585960511
Python
PyPy3 (2.4.0)
py
Runtime Error
162
38256
513
from heapq import heapify, _heapify_max, heappushpop, _heappushpop_max N = int(input()) numbers = [int(x) for x in input().split()] left = numbers[:N] heapify(left) right = numbers[2 * N:] _heapify_max(right) for x in numbers[N:2 * N]: if left[0] < x < right[0]: if abs(left[0] - x) > abs(left[0] - x): ...
s507811419
p03716
u219015402
1584059992
Python
Python (3.4.3)
py
Runtime Error
17
3064
603
import heapq N = int(input()) a_list = list(map(int,input().split())) bound = N # 前後の境 h_pre = [] h_post = [] for i in range(N): heapq.heappush(h_pre,a_list[i]) heapq.heappush(h_post,-1*a_list[-(i+1)]) pre_sum = [sum(h_pre)] post_sum = [sum(h_post)] for i in range(N): a = a_list[N+i] heapq.heappushpo...
s490809408
p03716
u784022244
1583600318
Python
Python (3.4.3)
py
Runtime Error
238
37212
889
from heapq import heapify, heappop, heappush N=int(input()) A=list(map(int, input().split())) class MaxHeap: def __init__(self, li): self.hp = [] for e in li: heappush(self.hp, -e) def push(self, x): heappush(self.hp, -x) def pop(self): ret = heappop(self.hp) ...
s498627219
p03716
u784022244
1583600162
Python
Python (3.4.3)
py
Runtime Error
236
37212
897
from heapq import heapify, heappop, heappush N=int(input()) A=list(map(int, input().split())) class MaxHeap: def __init__(self, li): self.hp = [] for e in li: heappush(self.hp, -e) def push(self, x): heappush(self.hp, -x) def pop(self): ret = heappop(self.hp) ...
s661389503
p03716
u784022244
1583600120
Python
Python (3.4.3)
py
Runtime Error
247
37212
889
from heapq import heapify, heappop, heappush N=int(input()) A=list(map(int, input().split())) class MaxHeap: def __init__(self, li): self.hp = [] for e in li: heappush(self.hp, -e) def push(self, x): heappush(self.hp, -x) def pop(self): ret = heappop(self.hp) ...
s679904458
p03716
u784022244
1583600028
Python
Python (3.4.3)
py
Runtime Error
99
37212
889
from heapq import heapify, heappop, heappush N=int(input()) A=list(map(int, input().split())) class MaxHeap: def __init__(self, li): self.hp = [] for e in li: heappush(self.hp, -e) def push(self, x): heappush(self.hp, -x) def pop(self): ret = heappop(self.hp) ...
s104531825
p03716
u784022244
1583599997
Python
Python (3.4.3)
py
Runtime Error
197
37212
857
import heapq N=int(input()) A=list(map(int, input().split())) class MaxHeap: def __init__(self, li): self.hp = [] for e in li: heappush(self.hp, -e) def push(self, x): heappush(self.hp, -x) def pop(self): ret = heappop(self.hp) ret *= -1 return ...
s939863551
p03716
u779455925
1583261717
Python
PyPy3 (2.4.0)
py
Runtime Error
652
121184
619
from collections import * from itertools import * from bisect import * from heapq import * import copy import math N=int(input()) A=list(map(int,input().split())) lst=A[:N] _sum=sum(lst) heapify(lst) sumlst=[0 for i in range(N*3)] sumlst[0]=_sum for i in range(N,2*N): heappush(lst,A[i]) a=heappop(lst) _s...
s677329795
p03716
u941407962
1582464147
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38384
583
H, W = map(int, input().split()) mnr = 10**9 for a in range(1, W//2 + 1): b1 = (H*W)//(a + W) b2 = b1+1 mc = max(abs((W-a)*b1-a*b1), abs(b1*(a+W) - H*W)) mc2 = max(abs((W-a)*b2-a*b2), abs(b2*(a+W) - H*W)) mnr = min([mnr, mc, mc2]) H, W = W, H for a in range(1, W//2 + 1): b1 = (H*W)//(a + W) ...
s464991576
p03716
u871980676
1580796256
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
674
import bisect import heapq import sys input = sys.stdin.readline N = int(input()) a = list(map(int,input().split())) a_left = sorted(a[:N]) a_right = sorted(a[N:]) sum_left = sum(a_left) sum_right = sum(a_right[:N]) res = sum_left - sum_right heapq.heapify(a_left) len_left = N for elem in a[N:2*N]: le = bisect.bi...
s816634188
p03716
u593567568
1577343069
Python
PyPy3 (2.4.0)
py
Runtime Error
444
114592
1484
import sys import heapq import copy def _heappush_max(heap, item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappop_max(heap): """Maxheap version of a heappop.""" lastelt = heap.pop() # raises appropriate IndexError if heap is empty if heap: returnitem = heap[0...
s733106922
p03716
u278356323
1573676616
Python
Python (3.4.3)
py
Runtime Error
191
38292
361
import heapq n = int(input()) a = list(map(int, input().split())) ans = 1-10**10 for i in range(n, 2*n+1): ll = a[:i] heapq.heapify(ll) for j in range(i-n): heapq.heappop(ll) rl = a[i:] heapq.heapify(rl) rsum = [heapq.heappop(rl) for _ in range(n)] ans = max(ans, sum(ll)-rsum) #...
s776774021
p03716
u557494880
1573454912
Python
Python (3.4.3)
py
Runtime Error
124
41172
374
N = int(input()) A = list(map(int,input().split())) S = [] for i in range(N+1): P = A[:(N+i)] Q = A[(N+i):] for l in range(len(Q)): Q[l] *= -1 heapq.heapify(P) heapq.heapify(Q) j = 0 k = 0 while j < i: heapq.heappop(P) while k < N-i: heapq.heappop(Q) s = s...
s570539824
p03716
u598229387
1569516474
Python
PyPy3 (2.4.0)
py
Runtime Error
198
40304
424
import heapq import numpy as np n=int(input()) a=[int(i) for i in input().split()] ans=float('-inf') for i in range(n+1): a_mae=sorted(a[:n+i],reverse=True) a_mae=list(map(lambda x:x*(-1),a_mae)) a_ushiro=sorted(a[n+i:]) mae=0 ushiro=0 for j in range(n): mae-=heapq.heappop(a_mae) ...
s856909493
p03716
u598229387
1569515633
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38640
404
import heapq import numpy as np n=int(input()) a=[int(i) for i in input().split()] ans=float('-inf') for i in range(n+1): a_mae=sorted(a[:n+i]) a_ushiro=sorted(a[n+i:],reverse=True) a_ushiro=list(map(lambda x:x*(-1),a_ushiro)) for j in range(i): heapq.heappop(a_mae) for k in range(n-i): ...
s987795543
p03716
u598229387
1569515007
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38640
420
import heapq import numpy as np n=int(input()) a=[int(i) for i in input().split()] ans=float('-inf') for i in range(n+1): a_mae=sorted(a[:n+i]) a_ushiro=sorted(a[n+i:],reverse=True) a_ushiro=np.array(a_ushiro) a_ushiro=list(a_ushiro*(-1)) for j in range(i): heapq.heappop(a_mae) for k ...
s312928282
p03716
u885899351
1559781264
Python
Python (3.4.3)
py
Runtime Error
115
37460
403
from collections import deque import heapq n=int(input()) s=list(map(int,input().split())) l=(s[:n]) heapq.heapify(l) r=[-i for i in s[2*n:]] heapq.heapify(r) c=deque(s[n:2*n]) x=l[0] y=r[0] while len(c)>0: a,b=c[0],-c[-1] if a-x>b-y: heappop(l) heappush(l,c.popleft()) x=l[0] else: ...
s142477357
p03716
u414425367
1557437763
Python
PyPy3 (2.4.0)
py
Runtime Error
184
39280
588
import numpy as np from heapq import heapreplace, heapify N=int(input()) A=np.array([int(a) for a in input().split(" ")]) lheap, rheap = list(A[:N]), list(-A[2*N:]) heapify(lheap) heapify(rheap) Lsum, Rsum = sum(lheap), sum(rheap) left = [Lsum] right = [Rsum] for i in range(N): if A[N+i] > lheap[0]: Lsum +...
s254703592
p03716
u367130284
1557174995
Python
Python (3.4.3)
py
Runtime Error
17
3064
225
def f(a):q=a[:n];heapify(q);return sum(q)+cumsum([e-heappushpop(q,e)for e in a[n:n-~n]]);from heapq import*;from numpy import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),f([-e for e in a[::-1]])[::-1]))))
s006735754
p03716
u367130284
1557173821
Python
Python (2.7.6)
py
Runtime Error
29
31804
207
def f(a): q=a[:n];s=sum(q);heapify(q) for e in a[n:n-~n]:yield s;s+=e-heappushpop(q,e) from heapq import*;r=raw_input;n,a=r(),map(int,r());print max(map(sum,zip(f(a),list(f([-e for e in a[::-1]]))[::-1])))
s938995468
p03716
u333768710
1555299219
Python
Python (3.4.3)
py
Runtime Error
2105
39144
3253
import math class MyHeap: def __init__(self, normal_list, smaller=True): self.smaller = smaller self.length = 0 self.list = [] for item in normal_list: self.heap_push(item) def heap_pop(self): top = self.list[0] bottom = self.list.pop() if t...
s848151721
p03716
u497596438
1555174867
Python
PyPy3 (2.4.0)
py
Runtime Error
275
108656
443
from heapq import * N=int(input()) A=map(int,input().split()) A.reverse() B=[] heap=[] for i in range(N): heappush(heap,A[i]) for i in range(N,2*N): if heap[0]<A[i]: B.append(heappop(heap)) heappush(heap,A[i]) else: B.append(A[i]) C=[] for i in range(2*N,3*N): if 2*B[-1]-A[i]-he...
s017353712
p03716
u310678820
1551578045
Python
Python (3.4.3)
py
Runtime Error
558
37212
638
import heapq n= int(input()) a=[int(i) for i in input().split()] heap1=[] heap2=[] a_max=[] b_max=[] s=0 for i in range(n): heapq.heappush(heap1, a[i]) s+=a[i] a_max.append(s) for i in range(n): heapq.heappush(heap1,a[n+i]) mini=heapq.heappop(heap1) s=s+a[n+i]-mini a_max.append(s) s=0 for i in r...
s016286976
p03716
u593005350
1538167697
Python
Python (3.4.3)
py
Runtime Error
110
39124
698
N=int(input()) b=list(map(int,input().split())) m=0 sd1=[] sd2=[] """ while m <= N: #d1=heapq.nlargest(N,b[:2*N-m]) d1=sorted(b[:2*N-m], reverse=True)[:N] #d2=heapq.nsmallest(N,b[2*N-m:]) d2=sorted(b[2*N-m:])[:N] Max.append(sum(d1)-sum(d2)) m+=1 """ d1=b[:N] sd1.append(sum(d1)) d2=b[2*N:] sd2.ap...
s730766032
p03716
u593005350
1538164536
Python
Python (3.4.3)
py
Runtime Error
2105
39012
461
N=int(input()) b=list(map(int,input().split())) Max=[] m=0 """ while m <= N: #d1=heapq.nlargest(N,b[:2*N-m]) d1=sorted(b[:2*N-m], reverse=True)[:N] #d2=heapq.nsmallest(N,b[2*N-m:]) d2=sorted(b[2*N-m:])[:N] Max.append(sum(d1)-sum(d2)) m+=1 """ d1=b[:N] while m<N: if min(d1) < b[N+m]: ...
s387049667
p03716
u593005350
1538164385
Python
Python (3.4.3)
py
Runtime Error
2105
39492
254
N=int(input()) b=list(map(int,input().split())) Max=[] m=0 d1=b[:N] while m<N: if min(d1) < b[N+m]: d1.remove((min(d1))) d1.append(b[N+m]) d2=sorted(b[N+m+1:])[:N] Max.append(sum(d1)-sum(d2)) m+=1 print(max(Max))
s425614025
p03716
u858136677
1537476736
Python
Python (3.4.3)
py
Runtime Error
2105
39268
822
import heapq import bisect n = int(input()) n = n*3 a = list(map(int,input().split())) big = a[0:n//3] big.sort() tempmin = a[n//3::] tempmin.sort() small = tempmin[0:n//3] spare = tempmin[n//3::] ans = sum(big)-sum(small) mxm = ans heapq.heapify(small) heapq.heapify(spare) for i in range(n//3,2*n//3): if len(...
s443979243
p03716
u858136677
1537476252
Python
Python (3.4.3)
py
Runtime Error
2104
37212
810
import heapq import bisect n = int(input()) n = n*3 a = list(map(int,input().split())) big = a[0:n//3] tempmin = a[n//3::] tempmin.sort() small = tempmin[0:n//3] spare = tempmin[n//3::] ans = sum(big)-sum(small) mxm = ans heapq.heapify(small) heapq.heapify(spare) for i in range(n//3,2*n//3): if len(spare) != 0...
s719888755
p03716
u858136677
1537474250
Python
Python (3.4.3)
py
Runtime Error
2108
37212
881
import bisect n = int(input()) n = n*3 a = list(map(int,input().split())) big = a[0:n//3] tempmin = a[n//3::] tempmin.sort() small = tempmin[0:n//3] spare = tempmin[n//3:] big.sort() small.sort() ans = sum(big)-sum(small) mxm = ans for i in range(n//3,2*n//3): if a[i] > big[0]: ans += a[i]-big[0] ...
s730477683
p03716
u243492642
1495375458
Python
PyPy3 (2.4.0)
py
Runtime Error
561
121100
1363
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI():...
s370876522
p03716
u243492642
1495375300
Python
Python (3.4.3)
py
Runtime Error
298
40272
1363
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI():...
s105720104
p03716
u327466606
1495343862
Python
Python (3.4.3)
py
Runtime Error
765
70472
1159
from heapq import * from collections import Counter N = int(input()) A = list(map(int, input().split())) A_indexed = [(a, i) for i, a in enumerate(A)] def scores(): # initial N:2N selected_left = A[:N] # min heap heapify(selected_left) l_score = sum(selected_left) temp = sorted(A[N:]) selected_right = C...
s583554594
p03716
u402629484
1495334360
Python
Python (3.4.3)
py
Runtime Error
103
37232
820
N = int(input()) a = list(map(int, input().split())) def exmax(x, y): if x is None: return y elif y is None: return x else: return max(x, y) memo = [None] * ((1 << 3 * N) + 1) def r(n, k, b): if 3 * N - n < N - k: return None elif memo[b] is not None: return...
s880805070
p03716
u243492642
1495334333
Python
PyPy3 (2.4.0)
py
Runtime Error
463
120404
1084
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): ...
s735838953
p03716
u692632484
1495334221
Python
Python (3.4.3)
py
Runtime Error
2105
37232
620
N=int(input()) a=[int(i) for i in input().split()] INF=-100000000000000 #前方Nと後方2Nで分割かつソート before=sorted(a[:N]) after=sorted(a[N:]) ans=INF left=sum(before) right=sum(after[:N]) borderR=after[N-1] for i in range(N): ans=max(ans,left-right) temp=a[N+i] after.remove(temp) if temp<=borderR: right-=temp right...
s637801728
p03716
u104282757
1495334190
Python
Python (3.4.3)
py
Runtime Error
1025
46136
1042
# D import numpy as np N = int(input()) A = np.array(list(map(int, input().split()))) # pop from left popleft = [0]*(N+1) A_LEFT = np.argsort(A[:(2*N)]) ind_left = 1 for i in range(N): while popleft[ind_left] > 0: ind_left += 1 if A_LEFT[i] < N: popleft[ind_left] = A[A_LEFT[i]] else: ...
s574414003
p03716
u692632484
1495334094
Python
Python (3.4.3)
py
Runtime Error
222
39124
582
N=int(input()) a=[int(i) for i in input().split()] INF=-100000000000000 #前方Nと後方2Nで分割かつソート before=sorted(a[:N]) after=sorted(a[N:]) ans=INF borderR=after[N-1] for i in range(N): ans=max(ans,left-right) temp=a[N+i] after.remove(temp) if temp<=borderR: right-=temp right+=after[N-1] if before[0]<temp: ...
s263341736
p03716
u104282757
1495334079
Python
Python (3.4.3)
py
Runtime Error
1012
47368
1044
# D import numpy as np N = int(input()) A = np.array(list(map(int, input().split()))) # pop from left popleft = [0]*(N+1) A_LEFT = np.argsort(A[:(2*N)]) ind_left = 1 for i in range(N): while popleft[ind_left] > 0: ind_left += 1 if A_LEFT[i] < N: popleft[ind_left] = A[A_LEFT[i]] else: ...
s296608097
p03716
u402629484
1495334078
Python
Python (3.4.3)
py
Runtime Error
94
39124
747
N = int(input()) a = list(map(int, input().split())) def exmax(x, y): if x is None: return y elif y is None: return x else: return max(x, y) memo = [None] * ((1 << 3 * N) + 1) def r(n, k, b): if 3 * N - n < N - k: return None elif memo[b] is not None: return...
s632762555
p03716
u402629484
1495333962
Python
Python (3.4.3)
py
Runtime Error
159
39124
711
N = int(input()) a = list(map(int, input().split())) def exmax(x, y): if x is None: return y elif y is None: return x else: return max(x, y) def r(n, k, b): if 3 * N - n < N - k: return None elif k == N: sf, sb = 0, 0 count = 0 for i in rang...
s412658207
p03716
u402629484
1495333904
Python
Python (3.4.3)
py
Runtime Error
94
37084
811
N = int(input()) a = list(map(int, input().split())) def exmax(x, y): if x is None: return y elif y is None: return x else: return max(x, y) memo = [None] * (1 << 3 * N) def r(n, k, b): if 3 * N - n < N - k: return None elif memo[b] is not None: return memo...
s387751863
p03716
u692632484
1495333831
Python
Python (3.4.3)
py
Runtime Error
2105
37232
523
N=int(input()) a=[int(i) for i in input().split()] INF=-100000000000000 #前方Nと後方2Nで分割かつソート before=sorted(a[:N]) after=sorted(a[N:]) ans=INF for i in range(N): left=sum(before) right=sum(after[:N]) ans=max(ans,left-right) after.remove(a[N+i]) if before[0]<a[N+i]: before.pop(0) for j in range(N): if a[N+i...
s221073679
p03716
u765237551
1495333789
Python
Python (3.4.3)
py
Runtime Error
177
38148
428
import heapq n = int(input()) xs = list(map(int, input().split())) head = heapq.heapify(xs[:n]) body = xs[n:2*n] body_and_tail = sorted(xs[n:]) sum_tail = sum(body_and_tail_list[:n]) unused_tail = heapq.heapify(body_and_tail[-n:]) ans = -1000000000000000000000 temp = sum(head) - sum_tail for b in body: heapq.push(h...
s704308559
p03716
u692632484
1495331550
Python
Python (3.4.3)
py
Runtime Error
2105
40724
456
N=int(input()) a=[int(i) for i in input().split()] INF=-10000000000000000 #前方Nと後方2Nで分割かつソート before=sorted(a[:N]) after=sorted(a[N:]) #print(before) #print(after) ans=INF for i in range(N): left=sum(before) right=sum(after[:N]) ans=max(ans,left-right) del after[N+i] if before[0]<a[N+i]: del before[0] befor...
s109292984
p03716
u243492642
1495330937
Python
Python (3.4.3)
py
Runtime Error
253
42316
1084
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): ...
s280533582
p03717
u905582793
1590470368
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38288
1066
from itertools import permutations n,m = map(int,input().split()) lrx = [list(map(int,input().split())) for i in range(m)] lrx.sort(key = lambda x:x[1]) mod = 10**9+7 dp = [[[0 for i in range(n+1)] for j in range(n+1)] for k in range(n+1)] dp[0][0][0] = 1 for l,r,t in lrx: if t != 1: for g in range(l): for ...
s208618728
p03717
u905582793
1590470104
Python
PyPy3 (2.4.0)
py
Runtime Error
175
38256
1263
from itertools import permutations n,m = map(int,input().split()) lrx = [list(map(int,input().split())) for i in range(m)] lrx.sort(key = lambda x:x[1]) mod = 10**9+7 dp = [[[0 for i in range(n+1)] for j in range(n+1)] for k in range(n+1)] dp[0][0][0] = 1 for l,r,t in lrx: if t != 1: for g in range(l): for ...
s714208834
p03717
u226155577
1519724826
Python
Python (3.4.3)
py
Runtime Error
2111
122348
1948
# seishin.py N, M = map(int, input().split()) r_min = [0]*(N+1); r_max = [N+1]*(N+1) g_min = [0]*(N+1); g_max = [N+1]*(N+1) for i in range(M): l, r, x = map(int, input().split()) # 仮定: R < G < B を元に各r,gの値の範囲を絞り込む(B = rになるため計算しない) if x == 1: # x = 1の時、あるrに紐づく全てのl_iについて G < l_i を満たす必要がある # =>...
s188017026
p03717
u226155577
1519723522
Python
Python (3.4.3)
py
Runtime Error
2110
159388
1795
# seishin.py from collections import deque N, M = map(int, input().split()) r_min = [0]*(N+1); r_max = [N+1]*(N+1) g_min = [0]*(N+1); g_max = [N+1]*(N+1) for i in range(M): l, r, x = map(int, input().split()) # 仮定: R < G < B を元に各r,gの値の範囲を絞り込む(B = rになるため計算しない) if x == 1: # x = 1の時、あるrに紐づく全てのl_iについて ...
s876281868
p03717
u424655672
1514891535
Python
Python (3.4.3)
py
Runtime Error
17
3060
1123
#include <bits/stdc++.h> #define REP(i,a,b) for(int i=(a);i<(b);i++) #define RREP(i,a,b) for(int i=(a);i>=(b);i--) #define pq priority_queue #define P pair<int,int> #define P2 pair<int,P> #define P3 pair<int,P2> typedef long long ll; typedef long double ld; using namespace std; const int INF=1e9, MOD=1e9+7, around[]={0...
s936462260
p03717
u327466606
1495693849
Python
Python (3.4.3)
py
Runtime Error
17
3064
516
x_sum = [3] y_sum = [3] s = 3 for pk in range(1,N): k = pk+1 for i,c in enumerate(map(sum,zip(x_sum,y_sum))): c %= MOD dp[i,pk] = c x_sum[i] += c x_sum.append(0) y_sum.append(2*s%MOD) s = 3*s%MOD subQ = Q[k] for i,j in list(dp.keys()): for l,x in subQ: if x != (l<=i)+(l<=j): ...
s673699357
p03717
u327466606
1495691180
Python
Python (3.4.3)
py
Runtime Error
22
3436
806
from collections import defaultdict MOD = 1000000007 iist = lambda: map(int,input().split()) N,M = iist() Q = defaultdict(list) for i in range(M): l,r,x = iist() Q[r].append((l,x)) if any(x != 1 for l,x in Q[1]): print(0) exit(0) dp = defaultdict(int) dp[0,0] = 3 x_sum = [3] y_sum = [3] s = 3 for pk in ra...
s954345213
p03718
u785989355
1600855961
Python
Python (3.8.2)
py
Runtime Error
33
9664
2984
code = """ # distutils: language=c++ # distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl] # cython: boundscheck=False # cython: wraparound=False from libcpp cimport bool from libcpp.vector cimport vector cdef extern from "<atcoder/maxflow>" namespace "atco...
s806478032
p03718
u535803878
1596858296
Python
Python (3.8.2)
py
Runtime Error
2214
349496
1519
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") h,w = list(map(int, input().split())) a = [None]*h for i in range(h): a[i] = input() if "S" in a[i]: start = (i*w+a[i].index("S")) if "T" in a[i]: go...
s934504159
p03718
u375616706
1593469059
Python
PyPy3 (7.3.0)
py
Runtime Error
1400
465928
3300
import sys#if RE->suspect recursion limit error from collections import deque sys.setrecursionlimit(10000) class Dinic: """max-flow-min-cut faster than ford-fulkerson algorithm O(|V||E|) """ def __init__(self,V:int): """ Arguments: V:num of vertex adj:adjeds...
s293467774
p03718
u375616706
1593469024
Python
PyPy3 (7.3.0)
py
Runtime Error
102
75224
3336
import sys#if RE->suspect recursion limit error from collections import deque sys.setrecursionlimit(10000) class Dinic: """max-flow-min-cut faster than ford-fulkerson algorithm O(|V||E|) """ def __init__(self,V:int): """ Arguments: V:num of vertex adj:adjeds...
s248768864
p03718
u375616706
1593467641
Python
PyPy3 (7.3.0)
py
Runtime Error
1290
471372
2643
class FordFulkerson: """max-flow-min-cut O(F|E|) """ def __init__(self,V:int): """ Arguments: V:num of vertex adj:adjedscent list(adj[from]=(to,capacity,id)) """ self.V = V self.adj=[[] for _ in range(V)] self.used=[False]*V d...