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
s568197496
p03732
u682181971
1494112261
Python
Python (3.4.3)
py
Runtime Error
18
3064
786
N,W = map(int, input().split()) w=[0 for i in range(N)] v=[0 for i in range(N)] Wsum = [0 for i in range(N+1)] Vsum = [0 for i in range(N+1)] for i in range(N): w[i],v[i] = map(int, input().split()) for i in range(N): Wsum[i+1] = Wsum[i] + w[i+1] Vsum[i+1] = Vsum[i] + v[i+1] w.insert(0,"0") v.insert(...
s754481589
p03732
u682181971
1494111731
Python
Python (3.4.3)
py
Runtime Error
18
3064
758
N,W = map(int, input().split()) w=[0 for i in range(N)] v=[0 for i in range(N)] Wsum = [0 for i in range(N+1)] Vsum = [0 for i in range(N+1)] for i in range(N): w,v = map(int, input().split()) for i in range(N): Wsum[i+1] = Wsum[i] + w[i+1] Vsum[i+1] = Vsum[i] + v[i+1] w.insert(0,"0") v.insert(0,"0"...
s147621513
p03732
u682181971
1494111613
Python
Python (3.4.3)
py
Runtime Error
18
3064
747
N,W = map(int, input().split()) w=[0 for i in range(N)] v=[0 for i in range(N)] Wsum = [0 for i in range(N+1)] Vsum = [0 for i in range(N+1)] for i in range(N): w,v = map(int, input().split()) for i in range(N): Wsum[i+1] = Wsum[i] + w[i+1] Vsum[i+1] = Vsum[i] + v[i+1] w.insert(0,"0") v.insert(0,"0") ...
s956013853
p03732
u682181971
1494111578
Python
Python (3.4.3)
py
Runtime Error
18
3064
747
N,W = map(int, input().split()) w=[0 for i in range(N)] v=[0 for i in range(N)] Wsum = [0 for i in range(N+1)] Vsum = [0 for i in range(N+1)] for i in range(N): w,v = map(int,input().split()) for i in range(N): Wsum[i+1] = Wsum[i] + w[i+1] Vsum[i+1] = Vsum[i] + v[i+1] w.insert(0,"0") v.insert(0,"0") ...
s101020031
p03732
u682181971
1494111494
Python
Python (3.4.3)
py
Runtime Error
18
3188
715
N,W = map(int, input().split()) w=[0 for i in range(N)] v=[0 for i in range(N)] Wsum = [0 for i in range(N+1)] Vsum = [0 for i in range(N+1)] for i in range(N): w,v = map(int,input().split()) for i in range(N): Wsum[i+1] = Wsum[i] + w[i+1] Vsum[i+1] = Vsum[i] + v[i+1] Wmin = min(w) nap_memo ={} ...
s442299606
p03732
u103099441
1493867970
Python
Python (3.4.3)
py
Runtime Error
21
3188
852
n, w = map(int, input().split()) w_d = {} w_l = [] for _ in range(3): w_i, v_i = map(int, input().split()) w_l.append(w_i) w_d[w_i] = [v_i] for i in range(3, n): w_i, v_i = map(int, input().split()) w_d[w_i].append(v_i) for i in range(3): w_d[w_l[i]] = sorted(w_d[w_l[i]], reverse=True) m = 0 fo...
s404578582
p03732
u912359563
1493862773
Python
Python (3.4.3)
py
Runtime Error
17
2940
1185
#include <bits/stdc++.h> using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<...
s397917007
p03732
u525555659
1493655285
Python
Python (3.4.3)
py
Runtime Error
17
3064
997
N,W = map(int, input().split()) w = [0 for i in range(N+1)] v = [0 for i in range(N+1)] Wsum = [0 for i in range(N+1)] Vsum = [0 for i in range(N+1)] #品物、重み→1〜N番目 for i in range(N): w[i+1],v[i+1] = map(int, input().split()) for i in range(N): Wsum[i+1] = Wsum[i] + w[i+1] Vsum[i+1] = Vsum[i] + v[i+1] #i...
s675563566
p03732
u525555659
1493655228
Python
Python (3.4.3)
py
Runtime Error
17
3064
997
N,W = map(int, input().split()) w = [0 for i in range(N+1)] v = [0 for i in range(N+1)] Wsum = [0 for i in range(N+1)] Vsum = [0 for i in range(N+1)] #品物、重み→1〜N番目 for i in range(N): w[i+1],v[i+1] = map(int, input().split()) for i in range(N): Wsum[i+1] = Wsum[i] + w[i+1] Vsum[i+1] = Vsum[i] + v[i+1] #i...
s949478824
p03732
u306843722
1493602104
Python
Python (2.7.6)
py
Runtime Error
1930
11652
508
#coding:utf-8 if __name__ == "__main__": N, W = map(int, raw_input().split(" ")) item = [] for i in range(N): item.append(map(int, raw_input().split(" "))) table = [[0 for j in range(W + 1)] for i in range(N)] for i in range(N): for j in range(W + 1): if item[i][0] <= ...
s437001077
p03732
u631914718
1493577053
Python
Python (3.4.3)
py
Runtime Error
18
3064
461
# coding: utf-8 if __name__ == "__main__": n, w = map(int,input().split()) v, w = [], [] for i in range(n): w_, v_ = map(int,input().split()) w.append(w_) v.append(v_) nap_memo = {} def nap(i,j): key = str(i)+':'+str(j) if key in nap_memo: return nap_memo[key] r = 0 if i == n: r = 0 elif...
s938718990
p03732
u902500155
1493531164
Python
Python (2.7.6)
py
Runtime Error
92
10544
1663
# coding: utf-8 # 整数の入力 #a = int(raw_input()) # スペース区切りの整数の入力 import numpy as np N, MaxTotalWeight = map(int, raw_input().split()) def getWeightValuePair(W,Values,WeightValuePair): totalValue = 0 WeightKeys = WeightValuePair.keys() WeightValuePairCopy = WeightValuePair.copy() for i in xrange(len(Value...
s802115888
p03732
u902500155
1493530009
Python
Python (2.7.6)
py
Runtime Error
11
2792
1649
# coding: utf-8 # 整数の入力 #a = int(raw_input()) # スペース区切りの整数の入力 N, MaxTotalWeight = map(int, raw_input().split()) def getWeightValuePair(W,Values,WeightValuePair): totalValue = 0 WeightKeys = WeightValuePair.keys() WeightValuePairCopy = WeightValuePair.copy() for i in range(len(Values)): totalVa...
s109799661
p03732
u902500155
1493528499
Python
Python (2.7.6)
py
Runtime Error
278
20464
1668
# coding: utf-8 # 整数の入力 #a = int(raw_input()) # スペース区切りの整数の入力 import numpy as np N, MaxTotalWeight = map(int, raw_input().split()) def getWeightValuePair(W,Values,WeightValuePair): totalValue = 0 WeightKeys = WeightValuePair.keys() WeightValuePairCopy = WeightValuePair.copy() for i in range(len(Values...
s377277534
p03732
u902500155
1493528431
Python
Python (2.7.6)
py
Runtime Error
263
19052
1704
# coding: utf-8 # 整数の入力 #a = int(raw_input()) # スペース区切りの整数の入力 import numpy as np N, MaxTotalWeight = map(int, raw_input().split()) def getWeightValuePair(W,Values,WeightValuePair): totalValue = 0 WeightKeys = WeightValuePair.keys() WeightValuePairCopy = WeightValuePair.copy() for i in range(len(Values...
s214315917
p03732
u786082266
1493522013
Python
Python (2.7.6)
py
Runtime Error
11
2948
329
n, l = map(int, raw_input().split()) dp = [-1 for j in range(10000)] for i in range(n): w, v = map(int, raw_input().split()) for j in reversed(range(ma)): if dp[j] != -1: dp[min(ma, j + w)] = max(dp[min(ma, j + w)], dp[j] + v) dp[w] = v dp[0] = 0 for i in reversed(range(l + 1)): if dp[i] != -1: print dp[i...
s305769739
p03732
u786082266
1493521779
Python
Python (2.7.6)
py
Runtime Error
2106
36672
343
n, l = map(int, raw_input().split()) ma = l * 200 + 5 dp = [-1 for j in range(ma)] for i in range(n): w, v = map(int, raw_input().split()) for j in reversed(range(ma)): if dp[j] != -1: dp[min(ma, j + w)] = max(dp[min(ma, j + w)], dp[j] + v) dp[w] = v dp[0] = 0 for i in reversed(range(l + 1)): if dp[i] != -1...
s606079894
p03732
u677421794
1493520485
Python
Python (2.7.6)
py
Runtime Error
2111
1974020
390
# -*- coding: utf-8 -*- n,weight = map(int, raw_input().split()) v = [0]*n w = [0]*n for i in range(n): w[i],v[i] = map(int, raw_input().split()) dp = [[0]*(weight+1)]*(n+1) for i in range(n): for j in range(weight+1): if (j < w[i]): dp[i+1][j] = dp[i][j]; else: dp[i+...
s666406436
p03732
u608297208
1493520464
Python
Python (3.4.3)
py
Runtime Error
175
13172
612
def f1(): L.sort(key = (lambda x: - x[1]//(x[0] - w1 + 40))) ans = 0 w2 = 0 i = 0 while i < N: w2 = w2 + L[i][0] if w2 > W: break ans = ans + L[i][1] i = i + 1 return ans def f2(): dp = [[0] * (W + 1) for i in range(N + 1)] for n in range(1,N + 1): w,v = L[n - 1] if w > W: continue for m ...
s677104400
p03732
u608297208
1493520055
Python
Python (3.4.3)
py
Runtime Error
174
13172
608
def f1(): L.sort(key = (lambda x: - x[1]//(w1 - x[0] + 1))) ans = 0 w2 = 0 i = 0 while i < N: w2 = w2 + L[i][0] if w2 > W: break ans = ans + L[i][1] i = i + 1 return ans def f2(): dp = [[0] * (W + 1) for i in range(N + 1)] for n in range(1,N + 1): w,v = L[n - 1] if w > W: continue for m i...
s503112274
p03732
u112902287
1493520035
Python
Python (3.4.3)
py
Runtime Error
381
21096
503
import numpy as np N, W = map(int, input().split()) w = np.array([]) v = np.array([]) for i in range(N): ww, vv = map(int, input().split()) w.append(ww) v.append(vv) from functools import lru_cache @lru_cache(maxsize = 10000) def d(i, j): if i == 0: if w[0] <= j: return v[0] ...
s775181401
p03732
u581309643
1493519994
Python
Python (3.4.3)
py
Runtime Error
1390
21512
518
import numpy as np N, W = map(int, input().split()) lw = [0] lv = [0] for i in range(N): w, v = map(int, input().split()) lw.append(w) lv.append(v) ar = np.array([0] * (N+1) * (W+1)).reshape(N+1,W+1) for i in range(1,N+1): for w in range(1,W+1): if lw[i] <= w: if lv[i] + ar[i-1, w...
s736601293
p03732
u341926204
1493519994
Python
Python (3.4.3)
py
Runtime Error
18
3064
589
def d(): n, w = map(int, input().split()) shop = [] for i in range(n): shop.append( list(map(int, input().split())) ) # s = sorted(shop, key= lambda item: item[1]/item[0], reverse=True) # print(n, w, s) best = 0 k = n-2 while k <= n: bag = [0, 0] i = 0 whi...
s761820827
p03732
u330205771
1493519984
Python
Python (2.7.6)
py
Runtime Error
265
19280
840
import numpy as np N, W = map(int, raw_input().split()) w = np.array([]) v = np.array([]) for i in range(N): temp0, temp1 = map(int, raw_input().split()) w = np.append(w, temp0) v = np.append(v, temp1) table = np.array([]) def searchTable(item, weight): for i in range(len(table)): if table[i]...
s435745218
p03732
u608297208
1493519950
Python
Python (3.4.3)
py
Runtime Error
176
13172
607
def f1(): L.sort(key = (lambda x: - x[1]/(w1 - x[0] + 1))) ans = 0 w2 = 0 i = 0 while i < N: w2 = w2 + L[i][0] if w2 > W: break ans = ans + L[i][1] i = i + 1 return ans def f2(): dp = [[0] * (W + 1) for i in range(N + 1)] for n in range(1,N + 1): w,v = L[n - 1] if w > W: continue for m in...
s436475987
p03732
u341926204
1493519939
Python
Python (3.4.3)
py
Runtime Error
18
3064
587
def d(): n, w = map(int, input().split()) shop = [] for i in range(n): shop.append( list(map(int, input().split())) ) # s = sorted(shop, key= lambda item: item[1]/item[0], reverse=True) # print(n, w, s) best = 0 k = 0 while k <= n: bag = [0, 0] i = 0 while...
s405832214
p03732
u608297208
1493519897
Python
Python (3.4.3)
py
Runtime Error
210
13172
601
def f1(): L.sort(key = (lambda x: - x[1]/(w1-x[0]))) ans = 0 w2 = 0 i = 0 while i < N: w2 = w2 + L[i][0] if w2 > W: break ans = ans + L[i][1] i = i + 1 return ans def f2(): dp = [[0] * (W + 1) for i in range(N + 1)] for n in range(1,N + 1): w,v = L[n - 1] if w > W: continue for m in range...
s448881937
p03732
u314057689
1493519894
Python
Python (3.4.3)
py
Runtime Error
36
3444
725
def main(): N, W = map(int, input().split()) w = [] v = [] for n in range(N): a, b = map(int, input().split()) w.append(a) v.append(b) if w[0] <= 400: # napsack dp = [[-1 for y in range(401)] for x in range(N+1)] for i in range(N+1): for j in ra...
s386557286
p03732
u581309643
1493519323
Python
Python (3.4.3)
py
Runtime Error
1401
23820
663
import numpy as np N, W = map(int, input().split()) lw = [0] lv = [0] for i in range(N): w, v = map(int, input().split()) lw.append(w) lv.append(v) ar = np.array([0] * (N+1) * (W+1)).reshape(N+1,W+1) ar_c = np.array([None] * (N+1) * (W+1)).reshape(N+1,W+1) for i in range(1,N+1): for w in range(1,W+1):...
s278041568
p03732
u330205771
1493519217
Python
Python (2.7.6)
py
Runtime Error
10
2696
794
N, W = map(int, raw_input().split()) w = [] v = [] for i in range(N): temp0, temp1 = map(int, raw_input().split()) w.append(temp0) v.append(temp1) table = [] def searchTable(item, weight): for i in range(len(table)): if table[i][0] == item and table[i][1] == weight: return True, t...
s472790542
p03732
u472492255
1493519055
Python
Python (3.4.3)
py
Runtime Error
18
3064
721
# coding: utf-8 import sys class BagItem(object): def __init__(self, w, v): super(BagItem, self).__init__() self.w = w self.v = v def cost_performance(self): return self.v / self.w n,w = [int(x) for x in input().rstrip().split(" ")] items = [] for i in range(n): nn, ww = ...
s684955870
p03732
u472492255
1493519003
Python
Python (3.4.3)
py
Runtime Error
18
3064
709
# coding: utf-8 import sys class BagItem(object): def __init__(self, w, v): super(BagItem, self).__init__() self.w = w self.v = v def cost_performance(self): return self.v / self.w n,w = [int(x) for x in input().rstrip().split(" ")] items = [] for i in range(n): nn, ww = ...
s257849908
p03732
u472492255
1493518956
Python
Python (3.4.3)
py
Runtime Error
18
3064
772
# coding: utf-8 import sys class BagItem(object): def __init__(self, w, v): super(BagItem, self).__init__() self.w = w self.v = v def cost_performance(self): return self.v / self.w n,w = [int(x) for x in input().rstrip().split(" ")] items = [] for i in range(n): nn, ww = ...
s894565901
p03732
u677421794
1493518732
Python
Python (2.7.6)
py
Runtime Error
2108
19256
425
# -*- coding: utf-8 -*- import numpy as np n,weight = map(int, raw_input().split()) v = [0]*n w = [0]*n for i in range(n): w[i],v[i] = map(int, raw_input().split()) dp = np.zeros((n+1,weight+1),dtype='int32') for i in range(n): for j in range(weight+1): if (j < w[i]): dp[i+1][j] = dp[...
s952905809
p03732
u330205771
1493518461
Python
Python (2.7.6)
py
Runtime Error
34
3332
596
N, W = map(int, raw_input().split()) w = [] v = [] for i in range(N): temp0, temp1 = map(int, raw_input().split()) w.append(temp0) v.append(temp1) table = [[-1] * max(W + 1, (sum(w)))] * (N + 1) def function(item, weight): if table[item][weight] != -1: return table[item][weight] if item =...
s651020066
p03732
u330205771
1493518404
Python
Python (2.7.6)
py
Runtime Error
68
3588
722
N, W = map(int, raw_input().split()) w = [] v = [] for i in range(N): temp0, temp1 = map(int, raw_input().split()) w.append(temp0) v.append(temp1) table = [[-1] * max(W + 1, (sum(w)))] * (N + 1) def function(item, weight): if table[item][weight] != -1: return table[item][weight] if item =...
s066871383
p03732
u902500155
1493518228
Python
Python (2.7.6)
py
Runtime Error
1434
19308
963
# coding: utf-8 # 整数の入力 #a = int(raw_input()) # スペース区切りの整数の入力 import numpy as np N, W = map(int, raw_input().split()) WeightValueMatrix = np.zeros((W+1, N)) data = [] for i in range(N): data.append(map(int, raw_input().split())) for i in range(N): if i == 0: for j in range(W+1): if j < da...
s636642256
p03732
u902500155
1493517830
Python
Python (2.7.6)
py
Runtime Error
1489
19432
1000
# coding: utf-8 # 整数の入力 #a = int(raw_input()) # スペース区切りの整数の入力 import numpy as np import itertools N, W = map(int, raw_input().split()) WeightValueMatrix = np.zeros((W+1, N)) data = [] for i in range(N): data.append(map(int, raw_input().split())) for i in range(N): if i == 0: for j in range(W+1): ...
s888427806
p03732
u608297208
1493517218
Python
Python (3.4.3)
py
Runtime Error
2065
1974388
297
N,W = map(int,input().split()) dp = [[0] * (W + 1) for i in range(N + 1)] for n in range(1,N + 1): w,v = map(int,input().split()) if w > W: continue for m in range(w): dp[n][m] = dp[n - 1][m] for m in range(w,W + 1): dp[n][m] = max(dp[n - 1][m - w] + v, dp[n - 1][m]) print(max(dp[-1]))
s414866761
p03732
u768951609
1493516903
Python
Python (2.7.6)
py
Runtime Error
3499
11652
399
N,W=map(int,raw_input().split(' ')) w=[] v=[] for _ in range(N): t_w,t_v=map(int,raw_input().split(' ')) w.append(t_w) v.append(t_v) dp=[[0 for i in range(W+1)] for j in range(N+1)] for i in range(N)[::-1]: for j in range(W+1): if j<w[i]: dp[i][j]=dp[i+1][j] else: ...
s816258744
p03732
u768951609
1493516254
Python
Python (2.7.6)
py
Runtime Error
2089
7812
439
N,W=map(int,raw_input().split(' ')) w=[] v=[] for _ in range(N): t_w,t_v=map(int,raw_input().split(' ')) w.append(t_w) v.append(t_v) def rec(i,j): if dp[i][j]>=0: return dp[i][j] if i==N: res=0 elif j<w[i]: res=rec(i+1,j) else: res=max(rec(i+1,j),rec(i+1,j...
s304232862
p03732
u996252264
1493516067
Python
Python (3.4.3)
py
Runtime Error
2126
353268
487
def rren(): return list(map(int, input().split())) N, Wei = rren() w = [] v = [] for _ in range(N): tempW , tempV = rren() w.append(tempW) v.append(tempV) dp = [[-1 for x in range(N+10)] for y in range(Wei+10)] def rec(i, j): if(dp[i][j] != -1): return dp[i][j] if(i == N): res = ...
s272269616
p03733
u616489782
1593540407
Python
Python (3.8.2)
py
Runtime Error
28
8992
249
N,T = map(int,input().split()); t = [int(x) for x in input().split()]; end = 0; ans = 0; for i in range(N) : if end > t[i] : ans += t[i] + T - end; else : ans += T; end += t[i] + T; #print(ans,end); print(ans);
s959373133
p03733
u814986259
1589675608
Python
Python (3.4.3)
py
Runtime Error
29
6964
181
N,T = map(int, input().split()) prev = 0 ans = 0 for i in range(N): t = int(input()) if prev+T <= t: ans += T else: ans += (t - prev) prev = t print(ans + T)
s235826919
p03733
u593567568
1589425115
Python
Python (3.8.2)
py
Runtime Error
204
55104
331
N,T = map(int,input().split()) A = list(map(int,input().split())) LST = [] for a in A: LST.append((a,1)) LST.append((a+T,-1)) LST.sort() prev = -1 s = 0 ans = 0 for x,y in A: if y == 1: if s == 0: prev = x else: s += 1 elif y == -1: s -= 1 if s == 0: ans += (x - prev) p...
s836966455
p03733
u798260206
1588714749
Python
Python (3.4.3)
py
Runtime Error
17
2940
185
n,T = map(int,input().split()) t = list(map(int,input().split()) A = [0]*n for i in range(n): if t[i]>T: A[i+1] = A[i] + T else: A[i+1] = A[i]+ t[i] print(A[n])
s337215973
p03733
u339199690
1587780679
Python
Python (3.4.3)
py
Runtime Error
151
26836
186
N, T = map(int, input().split()) t = list(map(int, input().split())) res = 0 for i in range(N - 1): res += min(T, t[i + 1] - t[i]) if t[-2] + T <= t[-1]: res += T print(res)
s428907086
p03733
u373047809
1587525101
Python
Python (3.4.3)
py
Runtime Error
128
25132
95
n, T, *t = map(int, open(0).read().split()) print(sum(min(t[i+1] - t[i], T) for i in range(n)))
s889311908
p03733
u218843509
1585087534
Python
PyPy3 (2.4.0)
py
Runtime Error
186
40176
1097
INF = 10**12 class Rmin(): def __init__(self, size): #the number of nodes is 2n-1 self.n = 1 << (size.bit_length()) self.node = [INF] * (2*self.n-1) def Access(self, x): return self.node[x+self.n-1] def Update(self, x, val): x += self.n-1 self.node[x] = val while x > 0: x = (x-1)>>1 self.node[...
s233298694
p03733
u150376070
1584373021
Python
Python (3.4.3)
py
Runtime Error
17
2940
3924
//include //------------------------------------------ #include <bits/stdc++.h> using namespace std; //typedef //------------------------------------------ using LL = int64_t; using VL = vector<LL>; using VVL = vector<VL>; using VS = vector<string>; using PLL = pair<LL, LL>; //container util //-----------------------...
s311980533
p03733
u063073794
1581439716
Python
Python (3.4.3)
py
Runtime Error
17
3060
196
satooh N, T = map(int, input().split()) t = list(map(int, input().split())) ans = 0 for i in range(N - 1): if t[i] + T <= t[i + 1]: ans += T else: ans += t[i + 1] - t[i] ans += T print(ans)
s683909633
p03733
u417014669
1577578061
Python
Python (3.4.3)
py
Runtime Error
69
25200
359
N,T=map(int,input().split()) s=list(map(int, input().split())) t=[0,3,5,7,100,110,200,300,311] ans=0 t_diff=[t[i+1]-t[i] for i in range(N-1)] print(t_diff) for i in t_diff: if i>T: ans+=T else: ans+=i # 差分で足し合わせたので最後は計算に入ってない、最後は必ず被らないのでTを加える print(ans+T)
s556286943
p03733
u623687794
1560656978
Python
Python (3.4.3)
py
Runtime Error
18
3060
192
n,t=map(int,input().split()) oyu=list(map(int,input.split())) inl=[] ans=n*t for i in range(n-1): inl.append(oyu[i+1]-oyu[i]) for i in range(n-1): if inl[i]<t: ans-=t-inl[i] print(ans)
s347321327
p03733
u463655976
1558804828
Python
Python (3.4.3)
py
Runtime Error
18
2940
217
N, T = input().split() f = None p = None ans = 0 for t in map(int, input().split()) if f is None: f = t p = t - f ans += T rest = p + T - (t - f) if rest > 0: ans -= rest p = t - f print(ans)
s361736879
p03733
u966000628
1558130400
Python
PyPy3 (2.4.0)
py
Runtime Error
263
85328
533
n,w = list(map(int,input().split())) lis = [] for i in range(n): lis.append(list(map(int,input().split()))) w_id = w - lis[0][0] for i in range(n): lis[i][0] -= lis[0][0] if w_id < 0: print(0) exit() dp = [[0 for _ in range(w_id+1)] for _ in range(n)] for i in range(w_id+1): if i >= lis[0][0]: d...
s208023954
p03733
u017271745
1557803413
Python
Python (3.4.3)
py
Runtime Error
17
2940
291
#include<bits/stdc++.h> using namespace std; int main(){ int N, T; cin >> N >> T; vector<int> t(N); for (int i=0; i<N; i++) cin >> t.at(i); int ans = T * N; for (int i=0; i<N-1; i++){ ans -= max(0, t.at(i) + T - t.at(i+1)); } cout << ans << endl; }
s536979226
p03733
u367130284
1556786985
Python
Python (3.4.3)
py
Runtime Error
40
19488
240
N,W=map(int,input().split()) from collections import* d=defaultdict(int) d[0]=0 for i in range(N): w,v=map(int,input().split()) for k,b in d.copy().items(): if k+w<=W: d[k+w]=max(b,d[k]+v) print(max(d.values()))
s410942717
p03733
u859897687
1556030291
Python
Python (3.4.3)
py
Runtime Error
35
20856
125
n,t=map(int,input().split()) k=1000000000 for i in map(int,input().split()): ans+=min(t,max(i-k,0)) k=i ans+=t print(ans)
s979383972
p03733
u782654209
1554852918
Python
Python (3.4.3)
py
Runtime Error
17
2940
142
N,T=map(int,input().split(' ')) times=[int(input()) for i in range(N)] print(sum([min(T, times[i+1]-times[i] for i in range(N-1))])+times[-1])
s409724160
p03733
u669696235
1549136924
Python
Python (3.4.3)
py
Runtime Error
68
26832
140
N,T=map(int,input().split()) t=list(map(int,input().split())) for i in range(0,len(t)-1): ans+=min(t[i+1]-t[i],T) ans+=T print(ans)
s431299971
p03733
u120553768
1495220134
Python
Python (3.4.3)
py
Runtime Error
17
2940
185
n, t = [int(x) for x in input().split(' ')] time = [int(x) for x in input().split(' ')] int ans = 0 for i = time: if i > t: ans += t else: ans += i print(ans)
s869027219
p03733
u327466606
1494831927
Python
Python (3.4.3)
py
Runtime Error
65
26964
301
N,W = map(int,input().split()) items = [tuple(map(int,input().split())) for i in range(N)] from collections import defaultdict dp = defaultdict(int) # w -> v dp[0] = 0 for w,v in items: for tw,tv in list(dp.items()): if tw+w <= W: dp[tw+w] = max(tv+v, dp[tw+w]) print(max(dp.values()))
s308564060
p03733
u252883287
1494471974
Python
Python (2.7.6)
py
Runtime Error
119
20036
341
#!/usr/bin/env python # coding: utf-8 N, T = map(int, raw_input().split(' ')) t = map(int, raw_input().split(' ')) assert len(t) == N begin = t[0] end = t[0] + T for i in range(N): if t[i] <= end: end = t[i] + T else: sum += (end - begin) begin = t[i] end = t[i] + T sum += (en...
s623371845
p03733
u063979080
1494125038
Python
Python (3.4.3)
py
Runtime Error
37
19216
259
def main(): line=input() line=line.split(' ') n=line[0] t=line[1] line=input() line=line.split(' ') total=0 for i in range(1,n): total+=min(t,line[i]-line[i-1]) print(total) if __name__=='__main__': main()
s072765451
p03733
u339443002
1493871075
Python
Python (2.7.6)
py
Runtime Error
89
20244
921
from collections import defaultdict as dd from itertools import izip def sol(n, w, wis, vis): rv = 0 best = dd(int) for i, (wi, vi) in enumerate(izip(wis, vis)): if wi < w: best[(wi, i)] = max(best[(wi, i)], vi) rv = max(vi, rv) frontline = [(i, wis[i], vis[i]) for i i...
s097146845
p03733
u557791172
1493783471
Python
Python (2.7.6)
py
Runtime Error
28
15760
624
#-*- coding: utf-8 -*- def knapsack2(items, W): N = len(items) C = [[0 for _i in xrange(W+1)] for _j in xrange(N+1)] for i in range(N+1)[1:]: v, w = items[i-1] for j in range(W+1)[1:]: if j < w: C[i][j] = C[i-1][j] else: C[i][j] = max(...
s821236679
p03733
u557791172
1493783348
Python
Python (2.7.6)
py
Runtime Error
10
2696
506
#-*- coding: utf-8 -*- def knapsack2(items, W): N = len(items) C = [[0 for _i in xrange(W+1)] for _j in xrange(N+1)] for i in range(N+1)[1:]: v, w = items[i-1] for j in range(W+1)[1:]: if j < w: C[i][j] = C[i-1][j] else: C[i][j] = max(C...
s295066818
p03733
u272028993
1493683449
Python
PyPy2 (5.6.0)
py
Runtime Error
34
28780
830
n=int(raw_input()) xy=[] for i in xrange(n): x,y=map(int,raw_input().split()) if x>y:x,y=y,x xy.append((x,y)) xy.sort() rmn=10**12;rmx=0;bmn=10**12;bmx=0 for i in xrange(n): x,y=xy[i] rmn=min(rmn,y) rmx=max(rmx,y) bmn=min(bmn,x) bmx=max(bmx,x) ans1=(rmx-rmn)*(bmx-bmn) cntmx=0;cntmn=0 for...
s569594005
p03733
u637175065
1493520073
Python
PyPy3 (2.4.0)
py
Runtime Error
315
67308
1711
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float...
s096510310
p03733
u872191059
1493518754
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38640
824
Rmax = 0 Rmin = 1000000000 Bmax = 0 Bmin = 1000000000 N = int(input()) xs = [] ys = [] arr = [] for i in range(N): x, y = map(int, input().split()) xs.append(x) ys.append(y) arr.append((max(x, y) / min(x, y), min(x, y), max(x, y))) arr = list(sorted(arr)) for (_, x, y) in arr: Rmin0 = min(Rmin, x)...
s887549506
p03733
u557791172
1493518590
Python
Python (2.7.6)
py
Runtime Error
40
22356
1481
import collections import functools import time class memoized(object): def __init__(self, func): self.func = func self.cache = {} def __call__(self, *args): if not isinstance(args, collections.Hashable): return self.func(*args) if args in self.cache: return se...
s698466013
p03733
u557791172
1493518271
Python
Python (2.7.6)
py
Runtime Error
36
22384
2504
import collections import functools class memoized(object): '''Decorator. Caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned (not reevaluated). ''' def __init__(self, func): self.func = func self.cache = {} ...
s549518994
p03734
u334712262
1599589424
Python
PyPy3 (7.3.0)
py
Runtime Error
160
83660
2083
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from fractions import Fraction from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacem...
s662005066
p03734
u334712262
1599589366
Python
PyPy3 (7.3.0)
py
Runtime Error
180
83600
2054
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from fractions import Fraction from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacem...
s168743531
p03734
u827202523
1593482066
Python
PyPy3 (7.3.0)
py
Runtime Error
177
86472
1765
import sys # from collections import defaultdict, deque # import math # import copy from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(input()) getList = lambda: list(map(int, input(...
s755059152
p03734
u346812984
1591124167
Python
Python (3.4.3)
py
Runtime Error
152
12508
1514
import sys from collections import defaultdict import numpy as np sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N, W = map(int, input().split()) d = defaultdict(list) w, v = map(int, input().split()) w1 = w d...
s238918365
p03734
u346812984
1591124137
Python
PyPy3 (2.4.0)
py
Runtime Error
163
38384
1514
import sys from collections import defaultdict import numpy as np sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N, W = map(int, input().split()) d = defaultdict(list) w, v = map(int, input().split()) w1 = w d...
s162293277
p03734
u346812984
1591123999
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38256
1503
import sys from collections import defaultdict import numpy as np sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N, W = map(int, input().split()) d = defaultdict(list) w, v = map(int, input().split()) w1 = w d...
s513017333
p03734
u814986259
1589719027
Python
Python (3.4.3)
py
Runtime Error
34
3316
939
import collections N, W = map(int, input().split()) wv = collections.defaultdict(list) w = 0 for i in range(N): a, b = map(int, input().split()) wv[a].append(b) if i == 0: w = a s = [[0]*(len(wv[w+i])+1) for i in range(4)] for i in range(4): wv[w + i].sort(reverse=True) for j, x in enumerat...
s908252969
p03734
u106778233
1588609606
Python
Python (3.4.3)
py
Runtime Error
18
3064
406
n,w=map(int,input().split()) WV=[] for i in range(n): w,v=map(int,input().split()) WV.append((w,v)) dp={} dp[0]=0 for w,v in WV: for i in JinA: if i+w>w: continue temp=dp[i] try: use=dp[i+w] dp[i+w]+=max(temp+v-use,0) except: d...
s369085461
p03734
u106778233
1588608588
Python
Python (3.4.3)
py
Runtime Error
2117
316916
264
n,w=map(int,input().split()) WV=[] for i in range(n): w,v=map(int,input().split()) WV.append((w,v)) dp=[0]*(w*2) for w,v in WV: for i in range(w+1): try: dp[i]=max(dp[i],dp[i-w]+v) except: dp[i]=dp[i] print(max(dp[:w+1]))
s032561401
p03734
u223663729
1587338965
Python
Python (3.4.3)
py
Runtime Error
18
3064
717
# AtCoder Regular Contest 073 # D - Simple Knapsack # https://atcoder.jp/contests/arc073/tasks/arc073_b from itertools import combinations_with_replacement, accumulate N, W, *A = map(int, open(0).read().split()) w0 = A[0] T = [[] for _ in [0]*4] M = [0]*4 for w, v in zip(*[iter(A)]*2): T[w-w0].append(v) M[w-w0...
s658040087
p03734
u599114793
1587177361
Python
Python (3.4.3)
py
Runtime Error
2121
1974516
365
n,l = map(int,input().split()) dp = [] for i in range(n+1): dp.append([0]*(l+1)) for i in range(1, n+1): w,v = map(int,input().split()) for j in range(l+1): if l < w: continue elif j < w <= l: dp[i][j] = dp[i-1][j] elif w <= j: dp[i][j] = max(dp[i-...
s644271752
p03734
u599114793
1587176570
Python
PyPy3 (2.4.0)
py
Runtime Error
1620
2004252
367
n,l = map(int,input().split()) dp = [] for i in range(n+1): dp.append([0]*(l+1)) for i in range(1, n+1): w,v = map(int,input().split()) for j in range(l+1): if l < w: continue elif j < w <= l: dp[i][j] = dp[i-1][j] elif w <= j <= l: dp[i][j] = max(...
s358999938
p03734
u599114793
1587176239
Python
PyPy3 (2.4.0)
py
Runtime Error
1211
2004124
346
n,l = map(int,input().split()) dp = [] for i in range(n+1): dp.append([0]*(l+1)) for i in range(1, n+1): w,v = map(int,input().split()) for j in range(l+1): if l < w: pass elif j < w: dp[i][j] = dp[i-1][j] else: dp[i][j] = max(dp[i-1][j], dp[i-1][j...
s528441353
p03734
u599114793
1587176005
Python
PyPy3 (2.4.0)
py
Runtime Error
1205
2004124
309
n,l = map(int,input().split()) dp = [] for i in range(n+1): dp.append([0]*(l+1)) for i in range(1, n+1): w,v = map(int,input().split()) for j in range(l+1): if j < w: dp[i][j] = dp[i-1][j] else: dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v) print(dp[n][l])
s411100555
p03734
u930705402
1587172267
Python
PyPy3 (2.4.0)
py
Runtime Error
2109
1188376
484
N,W=map(int,input().split()) weight=[0]*N;value=[0]*N sumv=0 for i in range(N): weight[i],value[i]=map(int,input().split()) sumv+=value[i] dp=[[10**12]*(sumv+1) for i in range(N+1)] dp[0][0]=0 for i in range(N): for j in range(sumv+1): if(value[i]<=j): dp[i+1][j]=min(dp[i][j-value[i]]+we...
s907426068
p03734
u231189826
1586638974
Python
Python (3.4.3)
py
Runtime Error
1726
1974516
387
N,W = list(map(int, input().split())) w = [] v = [] for _ in range(N): a,b = list(map(int, input().split())) w.append(a) v.append(b) dp = [[0]*(W+1) for _ in range(N+1)] for i in range(N): for j in range(W+1): if j - w[i] < 0: dp[i+1][j] = dp[i][j] else: dp[i+1]...
s968346992
p03734
u231189826
1586638786
Python
Python (3.4.3)
py
Runtime Error
1762
1974388
381
N,W = list(map(int, input().split())) w = [] v = [] for _ in range(N): a,b = list(map(int, input().split())) w.append(a) v.append(b) dp = [[0]*(W+1) for _ in range(N+1)] for i in range(N): for j in range(W+1): if j - w[i] < 0: dp[i+1][j] = dp[i][j] else: dp[i+1]...
s712131363
p03734
u231189826
1586638733
Python
Python (3.4.3)
py
Runtime Error
1956
1974388
381
N,W = list(map(int, input().split())) w = [] v = [] for _ in range(N): a,b = list(map(int, input().split())) w.append(a) v.append(b) dp = [[0]*(W+1) for _ in range(N+1)] for i in range(N): for j in range(W+1): if j - w[i] < 0: dp[i+1][j] = dp[i][j] else: dp[i+1]...
s102842619
p03734
u265250376
1585930111
Python
PyPy3 (2.4.0)
py
Runtime Error
279
67420
1375
N,W = map(int, input().split()) ws = [] vs = [] for i in range(N): w,v = map(int, input().split()) ws.append(w) vs.append(v) ws_m = [w-ws[0] for w in ws] sum_ws_m = sum(ws_m) """ i番目まで見て、n個選んでいて、重さがwのときのvの最大値 ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする dp[i][n][w] """ dp = [[[0]*(3*N+2) for i in range(N+1...
s202159116
p03734
u265250376
1585930075
Python
PyPy3 (2.4.0)
py
Runtime Error
292
67164
1375
N,W = map(int, input().split()) ws = [] vs = [] for i in range(N): w,v = map(int, input().split()) ws.append(w) vs.append(v) ws_m = [w-ws[0] for w in ws] sum_ws_m = sum(ws_m) """ i番目まで見て、n個選んでいて、重さがwのときのvの最大値 ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする dp[i][n][w] """ dp = [[[0]*(3*N+1) for i in range(N+1...
s330883483
p03734
u545368057
1585920055
Python
Python (3.4.3)
py
Runtime Error
1201
52836
1114
N,W = map(int, input().split()) ws = [] vs = [] for i in range(N): w,v = map(int, input().split()) ws.append(w) vs.append(v) ws_m = [w-ws[0] for w in ws] """ i番目まで見て、n個選んでいて、重さがwのときのvの最大値 ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする dp[i][n][w] """ dp = [[[-1]*(3*N+1) for i in range(N+1)] for j in range(N+1...
s458167801
p03734
u545368057
1585918098
Python
Python (3.4.3)
py
Runtime Error
89
27764
931
N,W = map(int, input().split()) ws = [] vs = [] for i in range(N): w,v = map(int, input().split()) ws.append(w) vs.append(v) ws_m = [w-ws[0] for w in ws] """ i番目まで見て、n個選んでいて、重さがwのときのvの最大値 ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする dp[i][n][w] """ dp = [[[-1]*(3*N+1) for i in range(N+1)] for j in range(N+1...
s889383311
p03734
u545368057
1585916867
Python
Python (3.4.3)
py
Runtime Error
122
27892
977
N,W = map(int, input().split()) ws = [] vs = [] for i in range(N): w,v = map(int, input().split()) ws.append(w) vs.append(v) ws_m = [w-ws[0] for w in ws] """ i番目まで見て、n個選んでいて、重さがwのときのvの最大値 ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする dp[i][n][w] """ dp = [[[-1]*(3*N+1) for i in range(N+1)] for j in range(N+1...
s624907793
p03734
u111365362
1582742909
Python
PyPy3 (2.4.0)
py
Runtime Error
341
54748
539
#13:32 n,u = map(int,input().split()) now = [[0 for _ in range(301)] for _ in range(101)] for i in range(n): w,v = map(int,input().split()) if i == 0: w0 = int(w) last = now now = [[0 for _ in range(301)] for _ in range(101)] for j in range(100): for k in range(298): now[j][k] = max(now[j][k],la...
s347637960
p03734
u111365362
1582742845
Python
PyPy3 (2.4.0)
py
Runtime Error
337
54924
539
#13:32 n,u = map(int,input().split()) now = [[0 for _ in range(301)] for _ in range(101)] for i in range(n): w,v = map(int,input().split()) if i == 0: w0 = int(w) last = now now = [[0 for _ in range(301)] for _ in range(101)] for j in range(100): for k in range(298): now[j][k] = max(now[j][k],la...
s833437803
p03734
u111365362
1582742726
Python
PyPy3 (2.4.0)
py
Runtime Error
346
54748
508
#13:32 n,u = map(int,input().split()) now = [[0 for _ in range(301)] for _ in range(101)] for i in range(n): w,v = map(int,input().split()) if i == 0: w0 = int(w) last = now now = [[0 for _ in range(301)] for _ in range(101)] for j in range(100): for k in range(298): now[j][k] = max(now[j][k],la...
s667750085
p03734
u111365362
1582742694
Python
PyPy3 (2.4.0)
py
Runtime Error
359
54748
507
#13:32 n,u = map(int,input().split()) now = [[0 for _ in range(301)] for _ in range(101)] for i in range(n): w,v = map(int,input().split()) if i == 0: w0 = int(w) last = now now = [[0 for _ in range(301)] for _ in range(101)] for j in range(100): for k in range(298): now[j][k] = max(now[j][k],la...
s398646289
p03734
u576917603
1582203525
Python
Python (3.4.3)
py
Runtime Error
2108
1156852
627
N,W=map(int,input().split()) w,v=[0]*N,[0]*N for i in range(N): w[i],v[i]=map(int,input().split()) V=sum(v) # dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値 dp=[[float("inf")]*(V+1) for _ in range(N+1)] dp[0][0]=0 for i in range(N): for j in range(V+1): # i+1番目を選ぶ場合 if j-v[i]>=0: dp[i+1][j]=min(dp[i+1][j], dp[...