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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s982805954 | p02263 | u573915636 | 1525847872 | Python | Python3 | py | Runtime Error | 0 | 0 | 211 | l=[]
c=0
s=input().split()
for i in s:
if i=="+":
l[c-2]=l[c-2]+l[c-1]
c=c-1
elif i=="-":
l[c-2]=l[c-2]-l[c-1]
c=c-1
elif i=="*":
l[c-2]=l[c-2]*l[c-1]
c=c-1
else:
l[c]=int(i)
c=c+1
printl[0]
|
s573840372 | p02263 | u687567104 | 1526023790 | Python | Python | py | Runtime Error | 0 | 0 | 685 | #include<iostream>
#include<stack>
int main() {
stack<int> S;
for (string s; cin >> s&&s != "$";) {
int a, b;
switch (s[0]) {
case '+':
b = S.top(); S.pop();
a = S.top(); S.pop();
S.push(a + b);
break;
case '-':
b = S.top(); S.pop();
a = S.top(); S.pop();
S.push(a - b);
break;
case '*':
b = S.top(); S.pop();
a = S.top(); S.pop();
S.push(a * b);
break;
default:
S.push(atoi(s.c_str()));
break;
}
}
cout << S.top() << endl;
return 0;
}
|
s446954084 | p02263 | u269391636 | 1526897176 | Python | Python3 | py | Runtime Error | 0 | 0 | 307 | lis = list(map(int,input().split()))
st = []
for i in lis:
if i == "+":
x = st.pop()
y = st.pop()
st.append(x+y)
elif i == "-":
x = st.pop()
y = st.pop()
st.append(y-x)
elif i == "*":
x = st.pop()
y = st.pop()
st.append(x*y)
else:
st.append(i)
print(st[0])
|
s745703567 | p02263 | u810922275 | 1527034611 | Python | Python3 | py | Runtime Error | 0 | 0 | 548 | import numpy as np
A=input().split()
stack=[]
for i in range(len(A)):
n=len(stack)
if A[i]=='*':
y=stack.pop(n-1)
x=stack.pop(n-2)
stack.append(int(x*y))
elif A[i]=='/':
y=stack.pop(n-1)
x=stack.pop(n-2)
stack.append(int(x/y))
elif A[i]=='+':
y=stack.pop(n-1)
x=stack.pop(n-2)
stack.append(int(x+y))
elif A[i]=='-':
y=stack.pop(n-1)
x=stack.pop(n-2)
stack.append(int(x-y))
else:
stack.append(int(A[i]))
print(stack[0])
|
s216163079 | p02263 | u878596989 | 1527424921 | Python | Python3 | py | Runtime Error | 20 | 5620 | 1013 | def RPN(a,b,c,stk):
if len(stk) == 0:
stk.append(cul(int(a),int(b),c))
else:
if a.isdigit():
if b.isdigit():
stk.append(cul(int(a),int(b),c))
else:
stk = [stk[0],(cul(int(stk[1]),int(a),b))]
else:
stk = [(cul(int(stk[0]),int(stk[1]),a))]
return stk
def cul(a,b,operand):
if operand == "+":
return a+b
elif operand == "-":
return a-b
elif operand == "*":
return a*b
elif operand == "/":
return a*1.0/b
i = 0
stk = []
li = list(input().split(' '))
while i < len(li)-3:
temp = len(stk)
stk = RPN(li[i],li[i+1],li[i+2],stk)
if len(stk) == temp + 1:
i = i + 3
else:
i = i + 2
if len(stk) == 2:
stk[0] = cul(stk[0],stk[1],li[len(li)-1])
if len(li) == 3:
print(cul(int(li[0]),int(li[1]),li[2]))
else:
print(int(stk[0]))
|
s608232325 | p02263 | u242415969 | 1529503196 | Python | Python3 | py | Runtime Error | 0 | 0 | 2031 | def plus(number_list):
return sum([int(num) for num in number_list])
def minus(number_list):
numbers = [int(num) for num in number_list]
return numbers[0] - sum(numbers[1:])
def multiply(number_list):
numbers = [int(num) for num in number_list]
def recrusive(repeat_num, list_):
if repeat_num == 0:
return list_[0]
else:
return recrusive(repeat_num -1,list_)*list_[repeat_num]
return [recrusive(i,number_list) for i in range(len(number_list))][-1]
def divide(number_list):
numbers = [int(num) for num in number_list]
def recrusive(repeat_num, list_):
if repeat_num == 0:
return list_[0]
else:
return recrusive(repeat_num -1,list_)/list_[repeat_num]
return [recrusive(i,number_list) for i in range(len(number_list))][-1]
store_result = []
store_num = []
result = 0
for i,c in enumerate(input_list.split()):
if i < len(input_list.split())-1:
print('result',result)
print('store_num',store_num)
print('store_result',store_result)
if c == '+' :
result = plus(store_num)
store_num = []
store_result.append(result)
elif c== "-":
result = minus(store_num)
store_num = []
store_result.append(result)
elif c =='*':
result = multiply(store_num)
store_num = []
store_result.append(result)
elif c == '/':
result = divide(store_num)
store_num = []
store_result.append(result)
else:
store_num.append(int(c))
else:
if c == '+' :
result = plus(store_result)
elif c== "-":
result = minus(store_result)
elif c =='*':
result = multiply(store_result)
elif c == '/':
result = divide(store_result)
print(result)
|
s225721655 | p02263 | u242415969 | 1529503279 | Python | Python3 | py | Runtime Error | 0 | 0 | 2042 | def plus(number_list):
return sum([int(num) for num in number_list])
def minus(number_list):
numbers = [int(num) for num in number_list]
return numbers[0] - sum(numbers[1:])
def multiply(number_list):
numbers = [int(num) for num in number_list]
def recrusive(repeat_num, list_):
if repeat_num == 0:
return list_[0]
else:
return recrusive(repeat_num -1,list_)*list_[repeat_num]
return [recrusive(i,number_list) for i in range(len(number_list))][-1]
def divide(number_list):
numbers = [int(num) for num in number_list]
def recrusive(repeat_num, list_):
if repeat_num == 0:
return list_[0]
else:
return recrusive(repeat_num -1,list_)/list_[repeat_num]
return [recrusive(i,number_list) for i in range(len(number_list))][-1]
store_result = []
store_num = []
result = 0
for i,c in enumerate(input_list.split()):
if i < len(input_list.split())-1:
print('result',result)
print('store_num',store_num)
print('store_result',store_result)
if c == '+' :
result = plus(store_num)
store_num = []
store_result.append(result)
elif c== "-":
result = minus(store_num)
store_num = []
store_result.append(result)
elif c =='*':
result = multiply(store_num)
store_num = []
store_result.append(result)
elif c == '/':
result = divide(store_num)
store_num = []
store_result.append(result)
else:
store_num.append(int(c))
else:
if c == '+' :
result = plus(store_result)
elif c== "-":
result = minus(store_result)
elif c =='*':
result = multiply(store_result)
elif c == '/':
result = divide(store_result)
print(result)
|
s823333981 | p02263 | u242415969 | 1529503450 | Python | Python3 | py | Runtime Error | 0 | 0 | 1932 | def plus(number_list):
return sum([int(num) for num in number_list])
def minus(number_list):
numbers = [int(num) for num in number_list]
return numbers[0] - sum(numbers[1:])
def multiply(number_list):
numbers = [int(num) for num in number_list]
def recrusive(repeat_num, list_):
if repeat_num == 0:
return list_[0]
else:
return recrusive(repeat_num -1,list_)*list_[repeat_num]
return [recrusive(i,number_list) for i in range(len(number_list))][-1]
def divide(number_list):
numbers = [int(num) for num in number_list]
def recrusive(repeat_num, list_):
if repeat_num == 0:
return list_[0]
else:
return recrusive(repeat_num -1,list_)/list_[repeat_num]
return [recrusive(i,number_list) for i in range(len(number_list))][-1]
store_result = []
store_num = []
result = 0
for i,c in enumerate(input_list.split()):
if i < len(input_list.split())-1:
if c == '+' :
result = plus(store_num)
store_num = []
store_result.append(result)
elif c== "-":
result = minus(store_num)
store_num = []
store_result.append(result)
elif c =='*':
result = multiply(store_num)
store_num = []
store_result.append(result)
elif c == '/':
result = divide(store_num)
store_num = []
store_result.append(result)
else:
store_num.append(int(c))
else:
if c == '+' :
result = plus(store_result)
elif c== "-":
result = minus(store_result)
elif c =='*':
result = multiply(store_result)
elif c == '/':
result = divide(store_result)
print(result)
|
s111151179 | p02263 | u242415969 | 1529503534 | Python | Python3 | py | Runtime Error | 0 | 0 | 1916 | def plus(number_list):
return sum([int(num) for num in number_list])
def minus(number_list):
numbers = [int(num) for num in number_list]
return numbers[0] - sum(numbers[1:])
def multiply(number_list):
numbers = [int(num) for num in number_list]
def recrusive(repeat_num, list_):
if repeat_num == 0:
return list_[0]
else:
return recrusive(repeat_num -1,list_)*list_[repeat_num]
return [recrusive(i,number_list) for i in range(len(number_list))][-1]
def divide(number_list):
numbers = [int(num) for num in number_list]
def recrusive(repeat_num, list_):
if repeat_num == 0:
return list_[0]
else:
return recrusive(repeat_num -1,list_)/list_[repeat_num]
return [recrusive(i,number_list) for i in range(len(number_list))][-1]
store_result = []
store_num = []
result = 0
for i,c in enumerate(input_list.split()):
if i < len(input_list.split())-1:
if c == '+' :
result = plus(store_num)
store_num = []
store_result.append(result)
elif c== "-":
result = minus(store_num)
store_num = []
store_result.append(result)
elif c =='*':
result = multiply(store_num)
store_num = []
store_result.append(result)
elif c == '/':
result = divide(store_num)
store_num = []
store_result.append(result)
else:
store_num.append(int(c))
else:
if c == '+' :
result = plus(store_result)
elif c== "-":
result = minus(store_result)
elif c =='*':
result = multiply(store_result)
elif c == '/':
result = divide(store_result)
print(str(result))
|
s131211956 | p02263 | u242415969 | 1529508927 | Python | Python3 | py | Runtime Error | 0 | 0 | 927 | stack = []
store_num = []
store_result = []
for i,c in enumerate(input_list.split()):
def pop_and_stack(list_,num):
list_.pop()
list_.pop()
list_.append(num)
return list_
if c == '+' :
a = stack[-2]
b = stack[-1]
num = a+b
pop_and_stack(stack,num)
elif c== "-":
a = stack[-2]
b = stack[-1]
num = a-b
pop_and_stack(stack,num)
elif c =='*':
a = stack[-2]
b = stack[-1]
num = a*b
pop_and_stack(stack,num)
elif c == '/':
a = stack[-2]
b = stack[-1]
num = a/b
pop_and_stack(stack,num)
else:
stack.append(int(c))
print(stack[-1])
|
s532894442 | p02263 | u242415969 | 1529509268 | Python | Python3 | py | Runtime Error | 0 | 0 | 917 |
stack = []
store_num = []
store_result = []
for i,c in enumerate(input_list.split()):
def pop_and_stack(list_,num):
list_.pop()
list_.pop()
list_.append(num)
return list_
if c == '+' :
a = stack[-2]
b = stack[-1]
num = a+b
pop_and_stack(stack,num)
elif c== "-":
a = stack[-2]
b = stack[-1]
num = a-b
pop_and_stack(stack,num)
elif c =='*':
a = stack[-2]
b = stack[-1]
num = a*b
pop_and_stack(stack,num)
elif c == '/':
a = stack[-2]
b = stack[-1]
num = a/b
pop_and_stack(stack,num)
else:
stack.append(int(c))
print(stack[-1])
|
s034297653 | p02263 | u242415969 | 1529509364 | Python | Python3 | py | Runtime Error | 0 | 0 | 900 | stack = []
store_num = []
store_result = []
for i,c in enumerate(input.split()):
def pop_and_stack(list_,num):
list_.pop()
list_.pop()
list_.append(num)
return list_
if c == '+' :
a = stack[-2]
b = stack[-1]
num = a+b
pop_and_stack(stack,num)
elif c== "-":
a = stack[-2]
b = stack[-1]
num = a-b
pop_and_stack(stack,num)
elif c =='*':
a = stack[-2]
b = stack[-1]
num = a*b
pop_and_stack(stack,num)
elif c == '/':
a = stack[-2]
b = stack[-1]
num = a/b
pop_and_stack(stack,num)
else:
stack.append(int(c))
print(stack[-1])
|
s124363196 | p02263 | u242415969 | 1529509397 | Python | Python3 | py | Runtime Error | 0 | 0 | 914 | stack = []
store_num = []
store_result = []
for i,c in enumerate(input.split()):
def pop_and_stack(list_,num):
list_.pop()
list_.pop()
list_.append(num)
return list_
if c == '+' :
a = stack[-2]
b = stack[-1]
num = a+b
pop_and_stack(stack,num)
elif c== "-":
a = stack[-2]
b = stack[-1]
num = a-b
pop_and_stack(stack,num)
elif c =='*':
a = stack[-2]
b = stack[-1]
num = a*b
pop_and_stack(stack,num)
elif c == '/':
a = stack[-2]
b = stack[-1]
num = a/b
pop_and_stack(stack,num)
else:
stack.append(int(c))
print(input())
#print(stack[-1])
|
s862379491 | p02263 | u242415969 | 1529509419 | Python | Python3 | py | Runtime Error | 0 | 0 | 916 | stack = []
store_num = []
store_result = []
for i,c in enumerate(input().split()):
def pop_and_stack(list_,num):
list_.pop()
list_.pop()
list_.append(num)
return list_
if c == '+' :
a = stack[-2]
b = stack[-1]
num = a+b
pop_and_stack(stack,num)
elif c== "-":
a = stack[-2]
b = stack[-1]
num = a-b
pop_and_stack(stack,num)
elif c =='*':
a = stack[-2]
b = stack[-1]
num = a*b
pop_and_stack(stack,num)
elif c == '/':
a = stack[-2]
b = stack[-1]
num = a/b
pop_and_stack(stack,num)
else:
stack.append(int(c))
print(input())
#print(stack[-1])
|
s640001621 | p02263 | u298224238 | 1529644595 | Python | Python3 | py | Runtime Error | 20 | 5612 | 652 | class Stack:
MAX = 100
def __init__(self):
self.S = [None] * self.__class__.MAX
self.top = 0
def is_empty(self):
return self.top == 0
def is_full(self):
return self.top >= self.__class__.MAX - 1
def push(self, x):
self.top += 1
self.S[self.top] = x
def pop(self):
self.top -= 1
return self.S[self.top + 1]
arr = [str(s) for s in input().split()]
stack = Stack()
for s in arr:
if s in ["+", "-", "*"]:
stack.push(
eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
else:
stack.push(int(s))
print(stack.pop())
|
s509520940 | p02263 | u298224238 | 1529644888 | Python | Python3 | py | Runtime Error | 0 | 0 | 614 | class Stack:
MAX = 101
def __init__(self):
self.S = [None] * self.__class__.MAX
self.top = 0
def is_empty(self):
return self.top == 0
def is_full(self):
return self.top >= self.__class__.MAX - 1
def push(self, x):
self.top += 1
self.S[self.top] = x
def pop(self):
self.top -= 1
return self.S[self.top + 1]
arr = [str(s) for s in input().split()]
stack = Stack()
stack.push(eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
if s in["+", "-", "*"] else stack.push(int(s)) for s in arr
print(stack.pop())
|
s871012953 | p02263 | u298224238 | 1529645066 | Python | Python3 | py | Runtime Error | 0 | 0 | 600 | class Stack:
MAX = 101
def __init__(self):
self.S = [None] * self.__class__.MAX
self.top = 0
def is_empty(self):
return self.top == 0
def is_full(self):
return self.top >= self.__class__.MAX - 1
def push(self, x):
self.top += 1
self.S[self.top] = x
def pop(self):
self.top -= 1
return self.S[self.top + 1]
stack = Stack()
[stack.push(eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
if s in["+", "-", "*"]else stack.push(int(s)) for s in str(s) for s in input().split()]
print(stack.pop())
|
s856507458 | p02263 | u298224238 | 1529645093 | Python | Python3 | py | Runtime Error | 0 | 0 | 618 | class Stack:
MAX = 101
def __init__(self):
self.S = [None] * self.__class__.MAX
self.top = 0
def is_empty(self):
return self.top == 0
def is_full(self):
return self.top >= self.__class__.MAX - 1
def push(self, x):
self.top += 1
self.S[self.top] = x
def pop(self):
self.top -= 1
return self.S[self.top + 1]
stack = Stack()
[stack.push(eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
if s in["+", "-", "*"]else stack.push(int(s)) for s in str(s) for s in [str(s) for s in input().split()]]
print(stack.pop())
|
s469948889 | p02263 | u292798607 | 1529916124 | Python | Python3 | py | Runtime Error | 0 | 0 | 578 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top,S[100];
void push(int x){
S[++top] = x;
}
int pop(){
top--;
return S[top+1];
}
int main(){
int a,b;
top = 0;
char s[100];
while( scanf("%s",s) != EOF){
if(s[0] == '+'){
a = pop();
b = pop();
push(a + b);
}
else if(s[0] == '-'){
b = pop();
a = pop();
push(a - b);
}
else if(s[0] == '*'){
a = pop();
b = pop();
push(a * b);
}
else{
push(atoi(s));
}
}
printf("%d\n",pop());
return 0;
}
|
s777281049 | p02263 | u929141425 | 1529917652 | Python | Python3 | py | Runtime Error | 20 | 5612 | 696 | def ch(x):
if x in ["+", "-", "*"]:
return x
else:
return int(x)
def check(x):
if (type(x[0]) is int) and (type(x[1]) is int) and (type(x[2]) is str):
return True
else:
return False
def calc(x):
if x[2] == "+":
return x[0] + x[1]
elif x[2] == "-":
return x[0] - x[1]
elif x[2] == "*":
return x[0] * x[1]
N = list(map(ch, input().split()))
st = []
while True:
if len(N) == 0:
break
elif len(st) in [0,1]:
st.append(calc(N[:3]))
N.pop(0); N.pop(0); N.pop(0);
elif len(st) == 2:
st.append(calc(st+[N[0]]))
N.pop(0); st.pop(0); st.pop(0);
print(*st)
|
s310017419 | p02263 | u207394722 | 1530210098 | Python | Python3 | py | Runtime Error | 0 | 0 | 716 | def main():
# データ入力
n, q = input().split()
n = int( n )
q = int( q )
name = []
time = []
for i in range(n):
tmp_n, tmp_t = input().split()
name.append( tmp_n )
time.append( int( tmp_t ) )
# 処理
count = 0
while n > 0:
if time[0] > q:
time[0] -= q
count += q
time.append( time[0] )
time.pop( 0 )
name.append( name[0] )
name.pop( 0 )
else :
count += time[0]
print( name[0], end=" " )
print( str( count ) )
time.pop( 0 )
name.pop( 0 )
n -= 1
if __name__ == '__main__':
main()
|
s340488802 | p02264 | u418996726 | 1531207265 | Python | Python3 | py | Runtime Error | 0 | 0 | 297 | import sys
n,q=map(int, input().split())
queue = list(map(lambda x: x.strip().split(),sys.stdin.readlines()))
i = 0
while len(queue) > 0:
if queue[i%len(queue)][1]-=q < 0:
print("{} {}".format(q[i%len(queue)][0], i*q + q + q[i%len(queue)][1]))
q.pop(i%len(queue))
i+=1
|
s284909717 | p02264 | u056253438 | 1535300430 | Python | Python3 | py | Runtime Error | 40 | 6284 | 864 | class a(object):
def __init__(self, buf_size=10000):
self.m = [None for _ in range(buf_size)]
self.ind = 0
self.cur = 0
def enqueue(self, elem):
self.m[self.ind] = elem
self.ind += 1
def dequeue(self):
if self.is_empty(): raise EOFError('this queue is empty')
result = self.m[self.cur]
self.cur += 1
return result
def is_empty(self):
return self.ind <=\
self.cur
n, q = input().split()
qe = a()
cur_time = 0
for _ in range(int(n)):
name, time = input().split()
qe.enqueue((name, int(time)))
while not qe.is_empty():
name, time = qe.dequeue()
if time > int(q):
cur_time += int(q)
time -= int(q)
qe.enqueue((name, time))
else:
cur_time += int(time)
print('{} {}'.format(name, cur_time))
|
s726555169 | p02264 | u056253438 | 1535300513 | Python | Python3 | py | Runtime Error | 0 | 0 | 864 | class a(object):
def __init__(self, buf_size=10000):
self.m = [None for _ in range(buf_size)]
self.ind = 0
self.cur = 0
def enqueue(self, elem):
self.m[self.ind] = elem
self.ind += 1
def dequeue(self):
if self.is_empty(): raise EOFError('this queue is empty')
result = self.m[self.cur]
self.cur += 1
return result
def is_empty(self):
return self.ind <=\
self.cur
n, q = input().split()
qe = a(n)
cur_time = 0
for _ in range(int(n)):
name, time = input().split()
qe.enqueue((name, int(time)))
while not qe.is_empty():
name, time = qe.dequeue()
if time > int(q):
cur_time += int(q)
time -= int(q)
qe.enqueue((name, time))
else:
cur_time += int(time)
print('{} {}'.format(name, cur_time))
|
s775334184 | p02264 | u356729014 | 1535689111 | Python | Python3 | py | Runtime Error | 0 | 0 | 365 | n,q = map(int,input().split())
tmp = [input().split() for i in range(n)]
a = [[name,int(time)] for name,time in tmp]
total_time = 0
count = 0
while(a):
current = a.pop
if(current[1] > q):
current[1] -= q
a.append(current)
total_time += q
else:
total_time += current[1]
print(current[0],total_time,sep = " ")
|
s656919106 | p02264 | u285980122 | 1535690368 | Python | Python3 | py | Runtime Error | 240 | 21568 | 1486 | class queue():
def __init__(self):
self.head = 0
self.tail = 0
self.MAX = 100000
self.Q = [[0] for i in range(self.MAX-1)]
def is_empty(self):
return self.head == self.tail
def is_full(self):
return self.head == (self.tail + 1) % self.MAX
def enqueue(self, x):
if self.is_full():
raise ValueError("エラー(オーバーフロー)")
self.Q[self.tail] = x
if self.tail + 1 == self.MAX:
self.tail = 0
else:
self.tail += 1
def dequeue(self):
if self.is_empty():
raise ValueError("エラー(アンダーフロー)")
x = self.Q[self.head]
if self.head + 1 == self.MAX:
self.head = 0
else:
self.head += 1
return x
n, q = input().split(" ")
n = int(n)
q = int(q)
q_name = queue()
q_val = queue()
for i in range(n):
name, t = input().split(" ")
t = int(t)
q_name.enqueue(name)
q_val.enqueue(t)
results = []
end_time = 0
while True:
process_val = q_val.dequeue()
process_name = q_name.dequeue()
if process_val <= q:
end_time += process_val
results.append([process_name, end_time])
else:
end_time += q
rest_val = process_val - q
q_name.enqueue(process_name)
q_val.enqueue(rest_val)
if q_val.head == q_val.tail:
break
for v in results:
print("{} {}".format(v[0],v[1]))
|
s910135500 | p02264 | u285980122 | 1535690542 | Python | Python3 | py | Runtime Error | 0 | 0 | 1487 | class queue():
def __init__(self):
self.head = 0
self.tail = 0
self.MAX = 100000
self.Q = [[0] for i in range(self.MAX-1)]
def is_empty(self):
return self.head == self.tail
def is_full(self):
return self.head == (self.tail + 1) % self.MAX
def enqueue(self, x):
if self.is_full():
raise ValueError("エラー(オーバーフロー)")
self.Q[self.tail] = x
if self.tail + 1 == self.MAX:
self.tail = 0
else:
self.tail += 1
def dequeue(self):
if self.is_empty():
raise ValueError("エラー(アンダーフロー)")
x = self.Q[self.head]
if self.head + 1 == self.MAX:
self.head = 0
else:
self.head += 1
return x
n, q = input().split(" ")
n = int(n)
q = int(q)
q_name = queue()
q_val = queue()
for i in range(n):
name, t = input().split(" ")
t = long(t)
q_name.enqueue(name)
q_val.enqueue(t)
results = []
end_time = 0
while True:
process_val = q_val.dequeue()
process_name = q_name.dequeue()
if process_val <= q:
end_time += process_val
results.append([process_name, end_time])
else:
end_time += q
rest_val = process_val - q
q_name.enqueue(process_name)
q_val.enqueue(rest_val)
if q_val.head == q_val.tail:
break
for v in results:
print("{} {}".format(v[0],v[1]))
|
s901309026 | p02264 | u840247626 | 1556109866 | Python | Python3 | py | Runtime Error | 0 | 0 | 269 | n,q = map(int,input().split())
queue = []
for i in range(n):
name,time = input().split()
queue.append((name, int(time)))
t = 0
i = 0
while queue:
p = queue[i % len(queue)]
t += min(q, p[1])
if p[1] > q:
p[1] -= q
i += 1
else:
print(p[0], t)
queue.pop(i)
|
s843648840 | p02264 | u840247626 | 1556110049 | Python | Python3 | py | Runtime Error | 0 | 0 | 273 | n,q = map(int,input().split())
queue = []
for i in range(n):
name,time = input().split()
queue.append((name, int(time)))
t = 0
i = 0
while queue:
i %= len(queue)
p = queue[i]
t += min(q, p[1])
if p[1] > q:
p[1] -= q
i += 1
else:
print(p[0], t)
queue.pop(i)
|
s761938904 | p02264 | u598089062 | 1559019333 | Python | Python3 | py | Runtime Error | 0 | 0 | 2320 | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
struct process {
string name;
int time;
};
class Queue {
private:
int head_;
int tail_;
public:
process queue[100001];
void initialize() {
head_ = 0;
tail_ = 0;
}
bool isEmpty() {
return head_ == tail_;
}
bool isFull() {
return head_ == (tail_ + 1) % 100001;
}
void enqueue(struct process ps) {
if (isFull()) {
cout << "Warning, queue is full" << endl;
}
queue[tail_] = ps;
if (tail_ + 1 == 100001) {
tail_ = 0;
}
else {
tail_++;
}
}
process dequeue() {
if (isEmpty()) {
cout << "Warning, queue is empty" << endl;
}
process ps = queue[head_];
if (head_ + 1 == 100001) {
head_ = 0;
}
else {
head_++;
}
return ps;
}
};
void test(void) {
process a = {"ABC", 123};
Queue q;
q.initialize();
q.enqueue(a);
q.enqueue({"BCD", 345});
process y = q.dequeue();
cout << y.name << endl;
process z = q.dequeue();
cout << z.name << endl;
}
int main(void) {
int processNum, quantum;
string processName;
int processTime;
int processTotalTime;
cin >> processNum >> quantum;
Queue processQ;
processQ.initialize();
// すべてのプロセスをキューに登録
for (int i=0; i < processNum; i++) {
cin >> processName >> processTime;
processQ.enqueue( {processName, processTime} );
}
// シミュレーション
while (processQ.isEmpty() == false) {
process target = processQ.dequeue();
if (target.time <= quantum) {
processTotalTime += target.time;
target.time = 0;
cout << target.name << " "<< processTotalTime << endl;
}
else {
processTotalTime += quantum;
target.time -= quantum;
processQ.enqueue(target);
}
}
return 0;
}
|
s692087029 | p02264 | u604774382 | 1433159511 | Python | Python3 | py | Runtime Error | 0 | 0 | 481 | from Queue import Queue
n, q = [ int( val ) for val in input( ).split( " " ) ]
names = Queue( )
times = Queue( )
for i in range( n ):
name, time = input( ).split( " " )
names.put( name )
times.put( int( time ) )
qsum = 0
output = []
while not times.empty( ):
name = names.get( )
time = times.get( )
if time <= q:
qsum += time
output.append( "{:s} {:d}".format( name, qsum ) )
else:
times.put( time - q )
names.put( name )
qsum += q
print( "\n".join( output ) ) |
s430374471 | p02264 | u669360983 | 1438328162 | Python | Python | py | Runtime Error | 0 | 0 | 329 | kl=[]
n,p=map(int,raw_input().split())
for i in range(n):
key,value=raw_input().split()
dict.update({key:int(value)})
kl.append(key)
cnt=0
time=0
while True:
for k in kl:
if dict[k]<=p:
cnt+=dict[k]
dict[k]=0
print k,cnt
del dict[k]
kl.remove(k)
time+=1
else:
dict[k]-=p
cnt+=p
if time==n: break |
s473471583 | p02264 | u669360983 | 1438328210 | Python | Python | py | Runtime Error | 0 | 0 | 329 | kl=[]
n,p=map(int,raw_input().split())
for i in range(n):
key,value=raw_input().split()
dict.update({key:int(value)})
kl.append(key)
cnt=0
time=0
while True:
for k in kl:
if dict[k]<=p:
cnt+=dict[k]
dict[k]=0
print k,cnt
del dict[k]
kl.remove(k)
time+=1
else:
dict[k]-=p
cnt+=p
if time==n: break |
s421331277 | p02264 | u313994256 | 1442303157 | Python | Python | py | Runtime Error | 0 | 0 | 364 | N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append(t[0],int(t[1]))
while A:
name, time = A.pop(0)
if time < q:
total += time
B.append(name, time)
else:
time -= q
total += q
A.append(name, time)
print " ".join() |
s173749411 | p02264 | u313994256 | 1442303248 | Python | Python | py | Runtime Error | 0 | 0 | 365 | N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append(t[0],int(t[1]))
while A:
name, time = A.pop(0)
if time < q:
total += time
B.append(name, time)
else:
time -= q
total += q
A.append(name, time)
print " ".join(B) |
s057526303 | p02264 | u313994256 | 1442303390 | Python | Python | py | Runtime Error | 0 | 0 | 366 | N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append(t[0],int(t[1]))
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append(name, time)
else:
time -= q
total += q
A.append(name, time)
print " ".join(B) |
s623664312 | p02264 | u313994256 | 1442303434 | Python | Python | py | Runtime Error | 0 | 0 | 369 | N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append(t[0],int(t[1]))
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append(name, time)
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s852590473 | p02264 | u313994256 | 1442303454 | Python | Python | py | Runtime Error | 0 | 0 | 371 | N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append(t[0],int(t[1]))
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append([name, time])
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s309562515 | p02264 | u313994256 | 1442303474 | Python | Python | py | Runtime Error | 0 | 0 | 371 | N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append(t[0],int(t[1]))
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append([name, time])
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s477778895 | p02264 | u313994256 | 1442303747 | Python | Python | py | Runtime Error | 0 | 0 | 379 | N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append(t[0],int(t[1]))
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append(name+" "+ str(total))
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s672786323 | p02264 | u313994256 | 1442303889 | Python | Python | py | Runtime Error | 0 | 0 | 381 | N_str, q_str = raw_input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append([t[0],int(t[1])])
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append(name+" "+ str(total))
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s233161856 | p02264 | u313994256 | 1442304005 | Python | Python | py | Runtime Error | 0 | 0 | 380 | N_str, q_str = raw_input().split()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().spilit()
A.append([t[0],int(t[1])])
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append(name+" "+ str(total))
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s332647415 | p02264 | u313994256 | 1442304024 | Python | Python | py | Runtime Error | 0 | 0 | 379 | N_str, q_str = raw_input().split()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().split()
A.append([t[0],int(t[1])])
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append(name+" "+ str(total))
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s558745580 | p02264 | u313994256 | 1442304108 | Python | Python | py | Runtime Error | 0 | 0 | 377 | N_str, q_str = raw_input().split()
N = int(N_str)
q = in(q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().split()
A.append([t[0],int(t[1])])
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append(name+" "+ str(total))
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s800311556 | p02264 | u313994256 | 1442304117 | Python | Python | py | Runtime Error | 0 | 0 | 378 | N_str, q_str = raw_input().split()
N = int(N_str)
q = int(q_str)
A =[]
B =[]
total =0
for i in N:
t = raw_input().split()
A.append([t[0],int(t[1])])
while A:
name, time = A.pop(0)
if time <= q:
total += time
B.append(name+" "+ str(total))
else:
time -= q
total += q
A.append([name, time])
print '\n'.join(B) |
s092053280 | p02264 | u894381890 | 1442368170 | Python | Python | py | Runtime Error | 10 | 6376 | 895 | import sys
def isEmpty(S):
if len(S) == 0:
return True
def enqueue(x):
x_list_list.append(x)
def dequeue(x_list_list):
if isEmpty(x_list_list):
print 'Error'
del_list = x_list_list[0]
x_list_list.pop(0)
return(del_list)
y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)
S = []
x_list_list = []
for i in range(a):
text = raw_input()
x_list = text.split()
x_list[1] = int(x_list[1])
x_list.append(0)
x_list_list.append(x_list)
flag = a
while flag != 0:
if int(x_list_list[0][1]) > b:
x_list_list[0][1] -= int(b)
for j in range(flag):
x_list_list[j][2] += b
del_list = dequeue(x_list_list)
enqueue(del_list)
elif int(x_list[0][1]) <= b:
for j in range(flag):
x_list_list[j][2] += x_list_list[0][1]
x_list_list[0][1] = 0
flag -= 1
print x_list_list[0][0],x_list_list[0][2]
dequeue(x_list_list) |
s205075792 | p02264 | u894381890 | 1442368311 | Python | Python | py | Runtime Error | 0 | 0 | 993 | import sys
def isEmpty(S):
if len(S) == 0:
return True
def isFull(S):
if len(S) >= 100000
return True
def enqueue(x):
if isFull(x_list_list):
print 'Error'
x_list_list.append(x)
def dequeue(x_list_list):
if isEmpty(x_list_list):
print 'Error'
del_list = x_list_list[0]
x_list_list.pop(0)
return(del_list)
y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)
S = []
x_list_list = []
for i in range(a):
text = raw_input()
x_list = text.split()
x_list[1] = int(x_list[1])
x_list.append(0)
x_list_list.append(x_list)
flag = a
while flag != 0:
if int(x_list_list[0][1]) > b:
x_list_list[0][1] -= int(b)
for j in range(flag):
x_list_list[j][2] += b
del_list = dequeue(x_list_list)
enqueue(del_list)
elif int(x_list[0][1]) <= b:
for j in range(flag):
x_list_list[j][2] += x_list_list[0][1]
x_list_list[0][1] = 0
flag -= 1
print x_list_list[0][0],x_list_list[0][2]
dequeue(x_list_list) |
s380278241 | p02264 | u894381890 | 1442368345 | Python | Python | py | Runtime Error | 10 | 6324 | 994 | import sys
def isEmpty(S):
if len(S) == 0:
return True
def isFull(S):
if len(S) >= 100000:
return True
def enqueue(x):
if isFull(x_list_list):
print 'Error'
x_list_list.append(x)
def dequeue(x_list_list):
if isEmpty(x_list_list):
print 'Error'
del_list = x_list_list[0]
x_list_list.pop(0)
return(del_list)
y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)
S = []
x_list_list = []
for i in range(a):
text = raw_input()
x_list = text.split()
x_list[1] = int(x_list[1])
x_list.append(0)
x_list_list.append(x_list)
flag = a
while flag != 0:
if int(x_list_list[0][1]) > b:
x_list_list[0][1] -= int(b)
for j in range(flag):
x_list_list[j][2] += b
del_list = dequeue(x_list_list)
enqueue(del_list)
elif int(x_list[0][1]) <= b:
for j in range(flag):
x_list_list[j][2] += x_list_list[0][1]
x_list_list[0][1] = 0
flag -= 1
print x_list_list[0][0],x_list_list[0][2]
dequeue(x_list_list) |
s651293276 | p02264 | u894381890 | 1442368460 | Python | Python | py | Runtime Error | 10 | 6364 | 995 | import sys
def isEmpty(S):
if len(S) == -1:
return True
def isFull(S):
if len(S) >= 100000:
return True
def enqueue(x):
if isFull(x_list_list):
print 'Error'
x_list_list.append(x)
def dequeue(x_list_list):
if isEmpty(x_list_list):
print 'Error'
del_list = x_list_list[0]
x_list_list.pop(0)
return(del_list)
y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)
S = []
x_list_list = []
for i in range(a):
text = raw_input()
x_list = text.split()
x_list[1] = int(x_list[1])
x_list.append(0)
x_list_list.append(x_list)
flag = a
while flag != 0:
if int(x_list_list[0][1]) > b:
x_list_list[0][1] -= int(b)
for j in range(flag):
x_list_list[j][2] += b
del_list = dequeue(x_list_list)
enqueue(del_list)
elif int(x_list[0][1]) <= b:
for j in range(flag):
x_list_list[j][2] += x_list_list[0][1]
x_list_list[0][1] = 0
flag -= 1
print x_list_list[0][0],x_list_list[0][2]
dequeue(x_list_list) |
s445823866 | p02264 | u894381890 | 1442368632 | Python | Python | py | Runtime Error | 10 | 6372 | 994 | import sys
def isEmpty(S):
if len(S) == 0:
return True
def isFull(S):
if len(S) >= 100000:
return True
def enqueue(x):
if isFull(x_list_list):
print 'Error'
x_list_list.append(x)
def dequeue(x_list_list):
if isEmpty(x_list_list):
print 'Error'
del_list = x_list_list[0]
x_list_list.pop(0)
return(del_list)
y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)
S = []
x_list_list = []
for i in range(a):
text = raw_input()
x_list = text.split()
x_list[1] = int(x_list[1])
x_list.append(0)
x_list_list.append(x_list)
flag = a
while flag != 0:
if int(x_list_list[0][1]) > b:
x_list_list[0][1] -= int(b)
for j in range(flag):
x_list_list[j][2] += b
del_list = dequeue(x_list_list)
enqueue(del_list)
elif int(x_list[0][1]) <= b:
for j in range(flag):
x_list_list[j][2] += x_list_list[0][1]
x_list_list[0][1] = 0
flag -= 1
print x_list_list[0][0],x_list_list[0][2]
dequeue(x_list_list) |
s872724283 | p02264 | u894381890 | 1442368812 | Python | Python | py | Runtime Error | 10 | 6324 | 802 | import sys
def enqueue(x):
x_list_list.append(x)
def dequeue(x_list_list):
del_list = x_list_list[0]
x_list_list.pop(0)
return(del_list)
y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)
S = []
x_list_list = []
for i in range(a):
text = raw_input()
x_list = text.split()
x_list[1] = int(x_list[1])
x_list.append(0)
x_list_list.append(x_list)
flag = a
while flag != 0:
if int(x_list_list[0][1]) > b:
x_list_list[0][1] -= int(b)
for j in range(flag):
x_list_list[j][2] += b
del_list = dequeue(x_list_list)
enqueue(del_list)
elif int(x_list[0][1]) <= b:
for j in range(flag):
x_list_list[j][2] += x_list_list[0][1]
x_list_list[0][1] = 0
flag -= 1
print x_list_list[0][0],x_list_list[0][2]
dequeue(x_list_list) |
s974512039 | p02264 | u894381890 | 1442368842 | Python | Python | py | Runtime Error | 10 | 6372 | 999 | import sys
def isEmpty(S):
if len(S) == 0:
return True
def isFull(S):
if len(S) >= 100000:
return True
def enqueue(x):
if isFull(x_list_list):
print 'Error'
x_list_list.append(x)
def dequeue(x_list_list):
if isEmpty(x_list_list):
print 'Error'
del_list = x_list_list[0]
x_list_list.pop(0)
return(del_list)
y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)
S = []
x_list_list = []
for i in range(a):
text = raw_input()
x_list = text.split()
x_list[1] = int(x_list[1])
x_list.append(0)
x_list_list.append(x_list)
flag = a
while flag != 0:
if int(x_list_list[0][1]) > b:
x_list_list[0][1] -= int(b)
for j in range(flag):
x_list_list[j][2] += b
del_list = dequeue(x_list_list)
enqueue(del_list)
elif int(x_list[0][1]) <= b:
for j in range(flag):
x_list_list[j][2] += x_list_list[0][1]
x_list_list[0][1] = 0
flag -= 1
print x_list_list[0][0],x_list_list[0][2]
dequeue(x_list_list)
|
s143124794 | p02264 | u197445199 | 1442370609 | Python | Python | py | Runtime Error | 0 | 0 | 733 | N = int(raw_input())
A = []
B = []
def insert(B, x):
B.insert(0, x)
return B
def delete(B, x):
i = 0
for num in B:
if num == x:
B.pop(i)
break
i += 1
return B
def deleteFirst(B):
B.pop(0)
return B
def deleteLast(B):
B.pop()
return B
operation = {'insert':insert, 'delete':delete, 'deleteFirst':deleteFirst, 'deleteLast':deleteLast}
for i in range(N):
a = raw_input().split()
if len(a) == 2:
A.append([a[0], int(a[1])])
else:
A.append([a[0]])
for item in A:
if len(item) == 2:
command, num = item
B = operation[command](B, num)
else:
command = item[0]
B = operation[command](B)
print B |
s014287105 | p02264 | u885889402 | 1442415241 | Python | Python3 | py | Runtime Error | 0 | 0 | 1426 | class Trio:
__pre=None
__val=None
__nex=None
def __init__(self,val,p=None,n=None):
self.__pre=p
self.__val=val
self.__nex=n
def get_pre(self):return self.__pre
def get_nex(self):return self.__nex
def set_pre(self,n):self.__pre=n
def set_nex(self,n):self.__nex=n
def set_val(self,n):self.__val=n
def get_val(self):return self.__val
class Queue:
top = back = None
def __init__(self):
pass
def enqueue(self,n):
if(self.top==None):
self.top = self.back = Trio(n)
else:
self.back.set_nex(Trio(n,p=self.back))
self.back=self.back.get_nex()
def dequeue(self):
if(self.top==self.back):
a,self.top,self.back=self.top.get_val(),None,None
return a
elif(self.top==None):
return None
else:
self.top=self.top.get_nex()
oldtop=self.top.get_pre()
self.top.set_pre(None)
return oldtop.get_val()
s = input()
n,limit=map(int,s.split())
que=Queue()
for i in range(n):
lis=input().split()
que.enqueue((lis[0],int(lis[1])))
time=0
while(True):
elm=que.dequeue()
if(elm==None):
break
elif(elm[1]>limit):
que.enqueue((elm[0],elm[1]-limit))
time+=100
else:
time+=elm[1]
print(elm[0],time) |
s005931741 | p02264 | u885889402 | 1442415276 | Python | Python3 | py | Runtime Error | 0 | 0 | 1426 | class Trio:
__pre=None
__val=None
__nex=None
def __init__(self,val,p=None,n=None):
self.__pre=p
self.__val=val
self.__nex=n
def get_pre(self):return self.__pre
def get_nex(self):return self.__nex
def set_pre(self,n):self.__pre=n
def set_nex(self,n):self.__nex=n
def set_val(self,n):self.__val=n
def get_val(self):return self.__val
class Queue:
top = back = None
def __init__(self):
pass
def enqueue(self,n):
if(self.top==None):
self.top = self.back = Trio(n)
else:
self.back.set_nex(Trio(n,p=self.back))
self.back=self.back.get_nex()
def dequeue(self):
if(self.top==self.back):
a,self.top,self.back=self.top.get_val(),None,None
return a
elif(self.top==None):
return None
else:
self.top=self.top.get_nex()
oldtop=self.top.get_pre()
self.top.set_pre(None)
return oldtop.get_val()
s = input()
n,limit=map(int,s.split())
que=Queue()
for i in range(n):
lis=input().split()
que.enqueue((lis[0],int(lis[1])))
time=0
while(True):
elm=que.dequeue()
if(elm==None):
break
elif(elm[1]>limit):
que.enqueue((elm[0],elm[1]-limit))
time+=100
else:
time+=elm[1]
print(elm[0],time) |
s907856332 | p02264 | u885889402 | 1442415289 | Python | Python3 | py | Runtime Error | 0 | 0 | 1426 | class Trio:
__pre=None
__val=None
__nex=None
def __init__(self,val,p=None,n=None):
self.__pre=p
self.__val=val
self.__nex=n
def get_pre(self):return self.__pre
def get_nex(self):return self.__nex
def set_pre(self,n):self.__pre=n
def set_nex(self,n):self.__nex=n
def set_val(self,n):self.__val=n
def get_val(self):return self.__val
class Queue:
top = back = None
def __init__(self):
pass
def enqueue(self,n):
if(self.top==None):
self.top = self.back = Trio(n)
else:
self.back.set_nex(Trio(n,p=self.back))
self.back=self.back.get_nex()
def dequeue(self):
if(self.top==self.back):
a,self.top,self.back=self.top.get_val(),None,None
return a
elif(self.top==None):
return None
else:
self.top=self.top.get_nex()
oldtop=self.top.get_pre()
self.top.set_pre(None)
return oldtop.get_val()
s = input()
n,limit=map(int,s.split())
que=Queue()
for i in range(n):
lis=input().split()
que.enqueue((lis[0],int(lis[1])))
time=0
while(True):
elm=que.dequeue()
if(elm==None):
break
elif(elm[1]>limit):
que.enqueue((elm[0],elm[1]-limit))
time+=100
else:
time+=elm[1]
print(elm[0],time) |
s042927741 | p02264 | u949338836 | 1444444900 | Python | Python3 | py | Runtime Error | 40 | 8036 | 615 | #coding:utf-8
#1_3_B
from collections import deque
def processing(queue, quantum, total_time):
""" queue must be deque object """
if not queue:
return
ps_name, ps_time = queue.popleft()
if ps_time <= quantum:
total_time += ps_time
print(ps_name, total_time)
else:
total_time += quantum
ps_time -= quantum
queue.append([ps_name, ps_time])
processing(queue, quantum, total_time)
n, quantum = map(int, input().split())
q = deque()
for i in range(n):
name, time = input().split()
q.append([name, int(time)])
processing(q, quantum, 0) |
s238552090 | p02264 | u963402991 | 1448443708 | Python | Python3 | py | Runtime Error | 0 | 0 | 589 | n, q = map(int, input().split())
q_list = collections.deque()
for i in range(n):
name, time = input().split()
q_list.append([name, int(time)])
time = 0
while q_list:
if q_list[0][1] == 0:
q_list.popleft()
elif q_list[0][1] == 100:
time += 100
print (q_list[0][0], time)
q_list[0][1] = 0
q_list.rotate(-1)
elif q_list[0][1] < 100:
time += q_list[0][1]
q_list[0][1] = 0
print (q_list[0][0], time)
q_list.rotate(-1)
else:
q_list[0][1] -= 100
time += 100
q_list.rotate(-1) |
s542039117 | p02264 | u685815919 | 1474344170 | Python | Python | py | Runtime Error | 0 | 0 | 598 | from collections import deque
class Process:
def __init__(self, name, time):
self.name = name
self.time = time
def getName(self):
return self.name
def getTime(self):
return self.time
def setTime(self, time):
self.time = time
queue = deque()
n, q = map(int, raw_input().split())
for _ in xrange(n):
name, time = raw_input().split()
queue.append(Process(name, int(time)))
t = 0
while nameq:
p = queue.popleft()
if p.getTime() > q:
p.setTime(p.getTime()-q)
queue.append(p)
t += q
else:
t += time
print "%s %d" % (p.getName(), p.getTime()) |
s825642687 | p02264 | u022407960 | 1477926827 | Python | Python3 | py | Runtime Error | 0 | 0 | 962 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def message_queue():
# write your code here
# tasks = deque(map(lambda x: x.split(), sys.stdin.readlines()))
task_num, task_time = map(int, input().split())
_input = sys.stdin.readlines()
# task_deque = deque([{'name': i.split()[0], 'time': int(i.split()[1])} for i in _input])
task_deque = deque(map(lambda x: dict(name=x.split()[0], time=x.split()[-1]), _input))
total_time = 0
while task_deque:
item = task_deque.popleft()
if item['time'] <= task_time:
total_time += item['time']
print(item['name'], total_time)
else:
item['time'] -= task_time
total_time += task_time
task_deque.append(item)
if __name__ == '__main__':
solution = Solution()
solution.message_queue() |
s411589047 | p02264 | u086566114 | 1479911492 | Python | Python | py | Runtime Error | 0 | 0 | 2609 | import time as ti
class MyQueue(object):
"""
My Queue class
Attributes:
queue: queue
head
tail
"""
def __init__(self):
"""Constructor
"""
self.length = 50005
self.queue = [0] * self.length
self.head = 0
self.tail = 0
# def enqueue(self, name, time):
def enqueue(self, process):
"""enqueue method
Args:
name: enqueued process name
time: enqueued process time
Returns:
None
"""
self.queue[self.tail] = process
self.tail = (self.tail + 1) % self.length
def dequeue(self):
"""dequeue method
Returns:
None
"""
self.queue[self.head] = 0
self.head = (self.head + 1) % self.length
def is_empty(self):
"""check queue is empty or not
Returns:
Bool
"""
if self.head == self.tail:
return True
else:
return False
def is_full(self):
"""chech whether queue is full or not"""
if self.tail - self.head >= len(self.queue):
return True
else:
return False
class Process(object):
"""process class
"""
def __init__(self, name="", time=0):
"""constructor
Args:
name: name
time: time
"""
self.name = name
self.time = time
def forward_time(self, time):
"""time forward method
Args:
time: forward time interval
Returns:
remain time
"""
self.time -= time
return self.time
def time_forward(my_queue, interval, current_time,):
"""
Args:
my_queue: queue
interval: time step interval
current_time: current time
"""
# value = my_queue.queue[my_queue.head].forward_time(interval)
value = my_queue.queue[my_queue.head] - interval
if value <= 0:
current_time += (interval + value)
print my_queue.queue[my_queue.head].name, current_time
my_queue.dequeue()
elif value > 0:
current_time += interval
my_queue.enqueue(my_queue.queue[my_queue.head])
my_queue.dequeue()
return current_time
my_queue = MyQueue()
n, q = [int(x) for x in raw_input().split()]
counter = 0
while counter < n:
name, time = raw_input().split()
my_queue.enqueue(Process(name, int(time)))
counter += 1
current_time = 0
while not my_queue.is_empty():
current_time = time_forward(my_queue, q, current_time) |
s187052454 | p02264 | u086566114 | 1479911498 | Python | Python | py | Runtime Error | 0 | 0 | 2609 | import time as ti
class MyQueue(object):
"""
My Queue class
Attributes:
queue: queue
head
tail
"""
def __init__(self):
"""Constructor
"""
self.length = 50005
self.queue = [0] * self.length
self.head = 0
self.tail = 0
# def enqueue(self, name, time):
def enqueue(self, process):
"""enqueue method
Args:
name: enqueued process name
time: enqueued process time
Returns:
None
"""
self.queue[self.tail] = process
self.tail = (self.tail + 1) % self.length
def dequeue(self):
"""dequeue method
Returns:
None
"""
self.queue[self.head] = 0
self.head = (self.head + 1) % self.length
def is_empty(self):
"""check queue is empty or not
Returns:
Bool
"""
if self.head == self.tail:
return True
else:
return False
def is_full(self):
"""chech whether queue is full or not"""
if self.tail - self.head >= len(self.queue):
return True
else:
return False
class Process(object):
"""process class
"""
def __init__(self, name="", time=0):
"""constructor
Args:
name: name
time: time
"""
self.name = name
self.time = time
def forward_time(self, time):
"""time forward method
Args:
time: forward time interval
Returns:
remain time
"""
self.time -= time
return self.time
def time_forward(my_queue, interval, current_time,):
"""
Args:
my_queue: queue
interval: time step interval
current_time: current time
"""
# value = my_queue.queue[my_queue.head].forward_time(interval)
value = my_queue.queue[my_queue.head] - interval
if value <= 0:
current_time += (interval + value)
print my_queue.queue[my_queue.head].name, current_time
my_queue.dequeue()
elif value > 0:
current_time += interval
my_queue.enqueue(my_queue.queue[my_queue.head])
my_queue.dequeue()
return current_time
my_queue = MyQueue()
n, q = [int(x) for x in raw_input().split()]
counter = 0
while counter < n:
name, time = raw_input().split()
my_queue.enqueue(Process(name, int(time)))
counter += 1
current_time = 0
while not my_queue.is_empty():
current_time = time_forward(my_queue, q, current_time) |
s412669561 | p02264 | u195186080 | 1480147949 | Python | Python3 | py | Runtime Error | 0 | 0 | 413 | import collections
q = collections.deque(maxlen=100000)
n = int(input())
for i in range(n):
com = input().split()
if com[0]=='insert':
q.appendleft(int(com[1]))
elif com[0]=='delete':
try:
q.remove(int(com[0]))
except ValueError:
pass
elif com[0]=='deleteFirst':
q.popleft()
elif com[0]=='deleteLast':
q.pop()
print(' '.join(q)) |
s704246609 | p02264 | u918276501 | 1485054650 | Python | Python3 | py | Runtime Error | 0 | 0 | 291 | n, q = map(int, input().split())
p = [input().split() for _ in range(n)]
t = i = 0
while n:
i = i % n
if int(p[i][1]) <= q:
t += int(p[i][1])
print(p[i][0], t)
del p[i]
n -= 1
else:
p[i][1] -= int(p[i][1]) - q
t += q
i += 1 |
s359294594 | p02264 | u895660619 | 1488070739 | Python | Python3 | py | Runtime Error | 0 | 0 | 864 | class queue:
head = tail = None
size = 0
def enqueue(self, x):
if self.is_empty():
self.head = self.tail = (x, None)
else:
self.tail[1] = (x, None)
self.tail = self.tail[1]
self.size += 1
def dequeue(self):
if not self.is_empty():
self.head = self.head[1]
self.size -=1
def is_empty(self):
return self.size == 0
n, q = map(int, input().split())
s = queue()
t = list()
process = 0
for i in range(n):
name, time = map(str, input().split())
s.enqueue([name, int(time)])
while s.is_empty():
diff = s[0][1] - q
if diff <= 0:
process += s[0][1]
t.append([s[0][0], process])
s.dequeue()
else:
process += q
s.enqueue([s[0][0], diff])
s.dequeue()
for i in t:
print(i[0], i[1]) |
s896314510 | p02264 | u300946041 | 1489776244 | Python | Python3 | py | Runtime Error | 0 | 0 | 658 | # encording: utf-8
n, q = [e for e in input().split()]
def main(n, q):
head = 0
tail = -1
lst = []
all_time = 0
for name, time in input().split():
lst.append([name, int(time)])
while head != tail:
name, time = lst[head][0], lst[head][1]
if time <= q:
all_time += time
print("{0} {1}".format(name, all_time))
if tail == len(lst) - 1:
tail = 0
else:
tail += 1
else:
all_time += time
if head == len(lst) - 1:
head = 0
else:
head +=1
print(main(n, q) |
s787902857 | p02264 | u297744593 | 1493450015 | Python | Python3 | py | Runtime Error | 0 | 0 | 624 | a = list(map(int, input().split()))
queuekey = []
queuetime = []
for i in range(0, a[0]):
tmp = list(input().split())
queuekey.append(tmp[0])
queuetime.append(int(tmp[1]))
spentTime = 0
while len(queue) > 0:
if queuetime[0] < a[1]:
spentTime += queuetime[0]
print(queuekey[0], end="")
print(' ', end="")
print(spentTime)
queuekey.pop(0)
queuetime.pop(0)
else:
spentTime += a[1]
queuetime[0] -= a[1]
queuetime.append(queletime[0])
queuekey.append(quelekey[0])
queuetime.pop(0)
queuekey.pop(0)
|
s442405009 | p02264 | u297744593 | 1493450050 | Python | Python3 | py | Runtime Error | 0 | 0 | 628 | a = list(map(int, input().split()))
queuekey = []
queuetime = []
for i in range(0, a[0]):
tmp = list(input().split())
queuekey.append(tmp[0])
queuetime.append(int(tmp[1]))
spentTime = 0
while len(queuetime) > 0:
if queuetime[0] < a[1]:
spentTime += queuetime[0]
print(queuekey[0], end="")
print(' ', end="")
print(spentTime)
queuekey.pop(0)
queuetime.pop(0)
else:
spentTime += a[1]
queuetime[0] -= a[1]
queuetime.append(queletime[0])
queuekey.append(quelekey[0])
queuetime.pop(0)
queuekey.pop(0)
|
s076590339 | p02264 | u603049633 | 1495955485 | Python | Python3 | py | Runtime Error | 0 | 0 | 510 | n,q = map(int, input().split())
Q = [0 for i in range(n+1)]
head = 0
tail = 0
def enqueue(x):
global tail
Q[tail] = ???
tail = (tail + 1) % (n + 1)
def dequeue():
global head
x,t = Q[head]
head = (head + 1) % (n + 1)
return [x,t]
for i in range(n):
P = input().split()
enqueue([P[0], int(P[1])])
elaps = 0
while head != tail:
u,t = dequeue()
c = min(q, t)
t -= c
elaps += c
if t > 0:
enqueue([u,t])
else:
print(u + " " + str(elaps)) |
s374750849 | p02264 | u603049633 | 1495955624 | Python | Python3 | py | Runtime Error | 0 | 0 | 510 | n,q = map(int, input().split())
Q = [0 for i in range(n+1)]
head = 0
tail = 0
def enqueue(x):
global tail
Q[tail] = ???
tail = (tail + 1) % (n + 1)
def dequeue():
global head
x,t = Q[head]
head = (head + 1) % (n + 1)
return [x,t]
for i in range(n):
P = input().split()
enqueue([P[0], int(P[1])])
elaps = 0
while head != tail:
u,t = dequeue()
c = min(q, t)
t -= c
elaps += c
if t > 0:
enqueue([u,t])
else:
print(u + " " + str(elaps)) |
s290852241 | p02264 | u603049633 | 1495956598 | Python | Python3 | py | Runtime Error | 0 | 0 | 510 | def enqueue(x):
global tail
Q[tail] = ???
tail = (tail + 1) % (n + 1)
def dequeue():
global head
x,t = Q[head]
head = (head + 1) % (n + 1)
return [x,t]
n,q = map(int, input().split())
Q = [0 for i in range(n+1)]
head = 0
tail = 0
for i in range(n):
P = input().split()
enqueue([P[0], int(P[1])])
elaps = 0
while head != tail:
u,t = dequeue()
c = min(q, t)
t -= c
elaps += c
if t > 0:
enqueue([u,t])
else:
print(u + " " + str(elaps)) |
s986429700 | p02264 | u603049633 | 1495956864 | Python | Python3 | py | Runtime Error | 0 | 0 | 508 | n,q = map(int, input().split())
Q = [0 for i in range(n+1)]
head = 0
tail = 0
def enqueue(x):
global tail
Q[tail] = ???
tail = (tail + 1) % (n + 1)
def dequeue():
global head
x,t = Q[head]
head = (head + 1) % (n + 1)
return [x,t]
for i in range(n):
P = input().split()
enqueue([P[0], int(P[1])])
elaps = 0
while head != tail:
u,t = dequeue()
c = min(q, t)
t -= c
elaps += c
if t > 0:
enqueue([u,t])
else:
print(u + " " + str(elaps)) |
s588689586 | p02264 | u603049633 | 1495957035 | Python | Python3 | py | Runtime Error | 0 | 0 | 514 | n,q = map(int, input().split())
MAX = n + 2
Q = [0 for i in range(MAX)]
head = 0
tail = 0
def enqueue(x):
global tail
Q[tail] = ???
tail = (tail + 1) % MAX
def dequeue():
global head
x,t = Q[head]
head = (head + 1) %MAX
return [x,t]
for i in range(n):
P = input().split()
enqueue([P[0], int(P[1])])
elaps = 0
while head != tail:
u,t = dequeue()
c = min(q, t)
t -= c
elaps += c
if t > 0:
enqueue([u,t])
else:
print(u + " " + str(elaps)) |
s379202939 | p02264 | u603049633 | 1495957159 | Python | Python3 | py | Runtime Error | 0 | 0 | 520 | n,q = map(int, input().split())
MAX = n + 2
Q = [0 for i in range(MAX)]
head = 0
tail = 0
def enqueue(x):
global tail
Q[tail] = ???
tail = (tail + 1) % MAX
def dequeue():
global head
x,t = Q[head]
head = (head + 1) %MAX
return [x,t]
for i in range(n):
P = list(input().split())
enqueue([P[0], int(P[1])])
elaps = 0
while head != tail:
u,t = dequeue()
c = min(q, t)
t -= c
elaps += c
if t > 0:
enqueue([u,t])
else:
print(u + " " + str(elaps)) |
s185396028 | p02264 | u735204496 | 1499003766 | Python | Python | py | Runtime Error | 0 | 0 | 713 | import Queue
import sys
class Proc:
def __init__(self, name, time):
self.time = time
self.name = name
def main():
array = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))
p_num = array[0]
q_time = array[1]
p_queue = Queue.Queue()
for i in range(0, p_num):
array = sys.readline().strip().split()
p_queue.put(Proc(array[0], int(array[1])))
t = 0
while not p_queue.empty():
p = p_queue.get()
if p.time > q_time:
p.time = p.time - q_time
p_queue.put(p)
t += q_time
else:
t += p.time
print p.name + " " + str(t)
if __name__ == "__main__":
main() |
s505286287 | p02264 | u735204496 | 1499003843 | Python | Python | py | Runtime Error | 0 | 0 | 716 | import Queue
import sys
class Proc:
def __init__(self, name, time):
self.time = time
self.name = name
def main():
array = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))
p_num = array[0]
q_time = array[1]
p_queue = Queue.Queue()
for i in range(0, p_num):
array = sys.readline().strip().split(" ")
p_queue.put(Proc(array[0], int(array[1])))
t = 0
while not p_queue.empty():
p = p_queue.get()
if p.time > q_time:
p.time = p.time - q_time
p_queue.put(p)
t += q_time
else:
t += p.time
print p.name + " " + str(t)
if __name__ == "__main__":
main() |
s426539780 | p02264 | u153665391 | 1504951586 | Python | Python3 | py | Runtime Error | 0 | 0 | 381 | N, Q = map(int, input().strip().split())
A = []
D = {}
for l in range(N):
n, t = input().strip().split()
D[n] = int(t)
A.append(n)
print(A)
T = 0
d = 0
while True:
n = A.pop(0)
if D[n] > Q:
D[n] -= Q
T += Q
A.append(n)
else:
T += D[n]
print(str(n) + ' ' + atr(T))
d += 1
if d == N:
break |
s883825186 | p02264 | u480053997 | 1508726200 | Python | Python3 | py | Runtime Error | 0 | 0 | 387 | ef ALDS1_3B():
n, q = map(int, input().split())
PQ = [[l[0], int(l[1])] for l in [input().split() for i in range(n)] ]
times = 0
while PQ:
p = PQ.pop(0)
if p[1] <= q:
times += p[1]
print('%s %d' %(p[0], times))
else:
times += q
PQ.append([p[0], p[1]-q])
if __name__ == '__main__':
ALDS1_3B() |
s184140559 | p02264 | u480053997 | 1508726376 | Python | Python3 | py | Runtime Error | 0 | 0 | 387 | ef ALDS1_3B():
n, q = map(int, input().split())
PQ = [[l[0], int(l[1])] for l in [input().split() for i in range(n)] ]
times = 0
while PQ:
p = PQ.pop(0)
if p[1] <= q:
times += p[1]
print('%s %d' %(p[0], times))
else:
times += q
PQ.append([p[0], p[1]-q])
if __name__ == '__main__':
ALDS1_3B() |
s966298493 | p02264 | u514487486 | 1509191710 | Python | Python3 | py | Runtime Error | 0 | 0 | 816 | n, q = map(int , input().split())
queue = []
for _ in range(n):
line = input().split()
queue.append([line[0], int(line[1])])
class my_queue:
def __init__(self, queue):
self.queue = queue
def enqueue(self, item):
self.queue = self.queue + [item]
self.queue.append(item)
def dequeue(self):
if len(self.queue) != 0:
item = self.queue[0]
self.queue = self.queue[1:]
else :
item = None
return item
time = 0
finish_task = []
while(True):
item = queue.pop()
if item == None:
break
elif item[1] <= q:
time += item[1]
finish_task.append([item[0], time])
else :
time += q
queue.append([item[0], item[1] - q])
for item in finish_task:
print(item[0], item[1]) |
s178232658 | p02264 | u530663965 | 1513601123 | Python | Python3 | py | Runtime Error | 30 | 6012 | 1008 | from collections import deque
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes = processes, time = process_time)
for r in result:
print(r.name, r.time)
def run_roundrobin(processes, time, total_time = 0, result=[]):
if not processes:
return result
p = processes.popleft()
if p.time <= time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return run_roundrobin(processes, time, total_time, result)
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main() |
s227555239 | p02264 | u530663965 | 1513601260 | Python | Python3 | py | Runtime Error | 30 | 15060 | 1048 | from collections import deque
import sys
sys.setrecursionlimit(10000)
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes = processes, time = process_time)
for r in result:
print(r.name, r.time)
def run_roundrobin(processes, time, total_time = 0, result=[]):
if not processes:
return result
p = processes.popleft()
if p.time <= time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return run_roundrobin(processes, time, total_time, result)
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main() |
s487256230 | p02264 | u530663965 | 1513601277 | Python | Python3 | py | Runtime Error | 70 | 63588 | 1050 | from collections import deque
import sys
sys.setrecursionlimit(1000000)
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes = processes, time = process_time)
for r in result:
print(r.name, r.time)
def run_roundrobin(processes, time, total_time = 0, result=[]):
if not processes:
return result
p = processes.popleft()
if p.time <= time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return run_roundrobin(processes, time, total_time, result)
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main() |
s307124672 | p02264 | u530663965 | 1513601325 | Python | Python3 | py | Runtime Error | 0 | 0 | 1054 | from collections import deque
import sys
sys.setrecursionlimit(10000000000)
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes = processes, time = process_time)
for r in result:
print(r.name, r.time)
def run_roundrobin(processes, time, total_time = 0, result=[]):
if not processes:
return result
p = processes.popleft()
if p.time <= time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return run_roundrobin(processes, time, total_time, result)
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main() |
s684396614 | p02264 | u530663965 | 1513601331 | Python | Python3 | py | Runtime Error | 60 | 63596 | 1052 | from collections import deque
import sys
sys.setrecursionlimit(100000000)
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes = processes, time = process_time)
for r in result:
print(r.name, r.time)
def run_roundrobin(processes, time, total_time = 0, result=[]):
if not processes:
return result
p = processes.popleft()
if p.time <= time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return run_roundrobin(processes, time, total_time, result)
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main() |
s982729435 | p02264 | u530663965 | 1513601338 | Python | Python3 | py | Runtime Error | 70 | 63588 | 1053 | from collections import deque
import sys
sys.setrecursionlimit(1000000000)
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes = processes, time = process_time)
for r in result:
print(r.name, r.time)
def run_roundrobin(processes, time, total_time = 0, result=[]):
if not processes:
return result
p = processes.popleft()
if p.time <= time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return run_roundrobin(processes, time, total_time, result)
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main() |
s568936011 | p02264 | u530663965 | 1513601344 | Python | Python3 | py | Runtime Error | 0 | 0 | 1054 | from collections import deque
import sys
sys.setrecursionlimit(10000000000)
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes = processes, time = process_time)
for r in result:
print(r.name, r.time)
def run_roundrobin(processes, time, total_time = 0, result=[]):
if not processes:
return result
p = processes.popleft()
if p.time <= time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return run_roundrobin(processes, time, total_time, result)
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main() |
s116275020 | p02264 | u150984829 | 1518302533 | Python | Python3 | py | Runtime Error | 0 | 0 | 224 | import sys
from collections import deque
n,q=map(int,input().split())
d=deque(map(lambda x,y:[x,int(y)],sys.stdin))
t=0
while d:
k,v=d.popleft()
v=int(v)
if v>q:
v-=q
t+=q
d.append([k,v])
else:
t+=v
print(k,t)
|
s566129296 | p02264 | u912143677 | 1519303364 | Python | Python | py | Runtime Error | 0 | 0 | 587 | n, q = [int(i) for i in input().split()]
name = []
time = []
for i in range(n):
x, y = [i for i in input().split()]
y = int(y)
name.append(x)
time.append(y)
from collections import deque
time = deque(time)
name = deque(name)
count = 0
time_out = []
name_out = []
while len(time) > 0:
a = time.popleft()
b = name.popleft()
if a > q:
a -= q
time.append(a)
name.append(b)
count += q
else:
count += a
time_out.append(count)
name_out.append(b)
for i, j in zip(name_out, time_out):
print(i, j)
|
s379950765 | p02264 | u150984829 | 1519867047 | Python | Python3 | py | Runtime Error | 0 | 0 | 313 | import sys
from collections import deque
def m():
s=sys.stdin.readlines()
q=int(s[0].split()[1])
f=lambda x,y:(x,int(y))
d=deque(map(*e.split())for e in s[1:])
t,a=0,[]
while d:
k,v=d.popleft()
if v>q:v-=q;t+=q;d.append([k,v])
else:t+=v;a+=[f'{k} {t}']
print('\n'.join(a))
if'__main__'==__name__:m()
|
s670195906 | p02264 | u702650865 | 1521857325 | Python | Python3 | py | Runtime Error | 0 | 0 | 569 | import sys
import numpy as np
import copy
fline = input().rstrip().split(' ')
N, Q = int(fline[0]), int(fline[1])
list = []
for i in range(N):
tlist = []
line = input().split(' ')
tlist = [line[0], line[1]]
#print(tlist)
list.append(tlist)
#print(list)
current = 0
while len(list) != 0:
if int(list[0][1]) <= Q:
current += int(list[0][1])
print(list[0][0] + " " + str(current))
del list[0]
else:
list[0][1] = str((int)(list[0][1])-Q)
list.append(list[0])
del list[0]
current += Q
|
s842203922 | p02264 | u702650865 | 1521857410 | Python | Python3 | py | Runtime Error | 0 | 0 | 585 | import sys
import numpy as np
import copy
fline = input().rstrip().split(' ')
N, Q = int(fline[0]), int(fline[1])
list = []
for i in range(N):
tlist = []
line = input().split(' ')
tlist = [line[0], line[1]]
#print(tlist)
list.append(tlist)
#print(list)
current = 0
while len(list) != 0:
if int(list[0][1]) <= Q:
current += int(list[0][1])
print(list[0][0] + " " + str(current))
del list[0]
else:
list[0][1] = str((int)(list[0][1])-Q)
list.append(list[0])
del list[0]
current += Q
#print(list)
|
s091217361 | p02264 | u464859367 | 1523155478 | Python | Python3 | py | Runtime Error | 0 | 0 | 693 | INPUT = list(map(int, input().split()))
head, tail, n, quantum = 0, len(processes), INPUT[0], INPUT[1]
processes = [input().split() for _ in range(n)]
def enqueue(x):
global processes, tail
processes.append(0)
processes[tail] = x
tail += 1
def dequeue():
global head
head += 1
for i in range(n):
int(processes[i][1])
time, count = 0, 0
while count < n:
y = processes[head][1] - quantum
if y < 0:
print(str(processes[head][0]) + " " + str(time + processes[head][1]))
dequeue()
time += y
count += 1
else:
processes[head][1] -= quantum
enqueue(processes[head])
dequeue()
time += quantum
|
s762469796 | p02264 | u464859367 | 1523155519 | Python | Python3 | py | Runtime Error | 0 | 0 | 693 | INPUT = list(map(int, input().split()))
processes = [input().split() for _ in range(n)]
head, tail, n, quantum = 0, len(processes), INPUT[0], INPUT[1]
def enqueue(x):
global processes, tail
processes.append(0)
processes[tail] = x
tail += 1
def dequeue():
global head
head += 1
for i in range(n):
int(processes[i][1])
time, count = 0, 0
while count < n:
y = processes[head][1] - quantum
if y < 0:
print(str(processes[head][0]) + " " + str(time + processes[head][1]))
dequeue()
time += y
count += 1
else:
processes[head][1] -= quantum
enqueue(processes[head])
dequeue()
time += quantum
|
s758783082 | p02264 | u464859367 | 1523155603 | Python | Python3 | py | Runtime Error | 0 | 0 | 700 | INPUT = list(map(int, input().split()))
processes = [input().split() for _ in range(INPUT[0])]
head, tail, n, quantum = 0, len(processes), INPUT[0], INPUT[1]
def enqueue(x):
global processes, tail
processes.append(0)
processes[tail] = x
tail += 1
def dequeue():
global head
head += 1
for i in range(n):
int(processes[i][1])
time, count = 0, 0
while count < n:
y = processes[head][1] - quantum
if y < 0:
print(str(processes[head][0]) + " " + str(time + processes[head][1]))
dequeue()
time += y
count += 1
else:
processes[head][1] -= quantum
enqueue(processes[head])
dequeue()
time += quantum
|
s997161748 | p02264 | u464859367 | 1523155806 | Python | Python3 | py | Runtime Error | 0 | 0 | 743 | INPUT = list(map(int, input().split()))
processes = [input() for _ in range(INPUT[0])]
for i in range(INPUT[0]):
processes[i].split()
head, tail, n, quantum = 0, len(processes), INPUT[0], INPUT[1]
def enqueue(x):
global processes, tail
processes.append(0)
processes[tail] = x
tail += 1
def dequeue():
global head
head += 1
for i in range(n):
int(processes[i][1])
time, count = 0, 0
while count < n:
y = processes[head][1] - quantum
if y < 0:
print(str(processes[head][0]) + " " + str(time + processes[head][1]))
dequeue()
time += y
count += 1
else:
processes[head][1] -= quantum
enqueue(processes[head])
dequeue()
time += quantum
|
s932188669 | p02264 | u464859367 | 1523156328 | Python | Python3 | py | Runtime Error | 0 | 0 | 728 | n, quantum = [int(i) for i in input().split()]
processes = []
for i in range(n):
processes.append(input())
for i in range(n):
processes[i].split()
head, tail = 0, len(processes)
def enqueue(x):
global processes, tail
processes.append(0)
processes[tail] = x
tail += 1
def dequeue():
global head
head += 1
for i in range(n):
int(processes[i][1])
time, count = 0, 0
while count < n:
y = processes[head][1] - quantum
if y < 0:
print(str(processes[head][0]) + " " + str(time + processes[head][1]))
dequeue()
time += y
count += 1
else:
processes[head][1] -= quantum
enqueue(processes[head])
dequeue()
time += quantum
|
s174724020 | p02264 | u464859367 | 1523157004 | Python | Python3 | py | Runtime Error | 0 | 0 | 713 | def parse(l):
name, time = l.split()
return name, int(time)
n, quantum = map(int, input().split())
queue = list(parse(input()) for _ in range(n))
head, tail = 0, len(queue)
def enqueue(x):
global queue, tail
queue.append(0)
queue[tail] = x
tail += 1
def dequeue():
global head
head += 1
for i in range(n):
int(queue[i][1])
total_time, count = 0, 0
while count < n:
y = queue[head][1] - quantum
if y < 0:
print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
dequeue()
total_time += y
count += 1
else:
queue[head][1] -= quantum
enqueue(queue[head])
dequeue()
total_time += quantum
|
s906838286 | p02264 | u464859367 | 1523158471 | Python | Python3 | py | Runtime Error | 0 | 0 | 615 | def parse(l):
name, time = l.split()
return name, int(time)
n, quantum = map(int, input().split())
queue = list(parse(input()) for _ in range(n))
head = 0
def enqueue(x):
global queue
queue.append(x)
def dequeue():
global head
head += 1
total_time, count = 0, 0
while count < n:
y = queue[head][1] - quantum
if y <= 0:
print(str(queue[head][0]) + " " + str(total_time + queue[head][1]))
dequeue()
total_time += y
count += 1
else:
queue[head][1] -= quantum
enqueue(queue[head])
dequeue()
total_time += quantum
|
s733111781 | p02264 | u564464686 | 1524819300 | Python | Python3 | py | Runtime Error | 0 | 0 | 391 | s=0
A=input().split()
n=(int)(A[0])
t=(int)(A[1])
x=[0 for i in range(2*n)]
for i in range(n):
B=input().split()
k=2*i
x[k]=(B[0])
x[k+1]=(int)(B[1])
while len(x)>0:
s=x[1]-t
if s>0:
sum+=t
x.append(x[0])
x.append(s)
del x[0]
del x[0]
if s<=0:
sum+=x[1]
print( x[0],sum)
del x[0]
del x[0]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.