buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k | change_count int64 0 100 |
|---|---|---|---|---|---|
#!/usr/bin/env python
# encoding: utf-8
class Solution:
def __init__(self):
self.count = 0
def shell_sort(self):
array_length = int(input())
array = []
for m in range(array_length):
array.append(str(input()))
G = [0]
while True:
g = G[0... | #!/usr/bin/env python
# encoding: utf-8
class Solution:
def __init__(self):
self.count = 0
def shell_sort(self):
array_length = int(input())
array = []
# array_length = 10
# array = [15, 12, 8, 9, 3, 2, 7, 2, 11, 1]
for m in range(array_length):
arr... | [["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 634, 0, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 612]] | 5 | 259 | 35 |
def insertion_sort(r, n, g):
cnt = 0
for i in range(g, n):
v = r[i]
j = i - g
while v < r[j] and j >= 0:
r[j + g] = r[j]
j = j - g
cnt += 1
r[j + g] = v
def shell_sort(r, n):
global m
global G
h = 1
while True:
if h > ... | def insertion_sort(r, n, g):
global cnt
for i in range(g, n):
v = r[i]
j = i - g
while v < r[j] and j >= 0:
r[j + g] = r[j]
j = j - g
cnt += 1
r[j + g] = v
def shell_sort(r, n):
global m
global G
h = 1
while True:
if h... | [["+", 0, 656, 0, 14, 8, 196, 0, 299, 0, 636], ["-", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 209 | 3 |
def insertion_sort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j -= g
cnt += 1
A[j + g] = v
def shell_sort(A, n):
G = []
i = 1
while i < n:
G[0:0] = [i]
... | def insertion_sort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j -= g
cnt += 1
A[j + g] = v
def shell_sort(A, n):
G = []
i = 1
while i <= n:
G[0:0] = [i]
... | [["-", 0, 14, 8, 196, 0, 52, 15, 666, 667, 18], ["+", 0, 14, 8, 196, 0, 52, 15, 666, 667, 19], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 207 | 4 |
import sys
import math
def insertion_sort(A, n, g):
cnt = 0
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j = j - g
cnt += 1
A[j + g] = v
return cnt
def shell_sort(A, n):
cnt = 0
m = math.ceil(math.log(2 * n + 1) / math.log(3))
print(m)
G = [0 for i ... | import sys
import math
def insertion_sort(A, n, g):
cnt = 0
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j = j - g
cnt += 1
A[j + g] = v
return cnt
def shell_sort(A, n):
cnt = 0
m = math.floor(math.log(2 * n + 1) / math.log(3))
print(m)
G = [0 for i... | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]] | 5 | 307 | 2 |
def insertionSort(A,n,g,cnt):
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
return A,cnt
def shellSort(A,n):
cnt = 0
G = [1]
while G[-1] <= n:
G.append(G[-1]*3 + 1)
G = G[::-1]
m = len(G)
for g in G:
A,cnt = insertionSort(A,n... | def insertionSort(A,n,g,cnt):
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
return A,cnt
def shellSort(A,n):
cnt = 0
G = [1]
while G[-1]*3+1 <= n:
G.append(G[-1]*3 + 1)
G = G[::-1]
m = len(G)
for g in G:
A,cnt = insertionSort... | [["+", 0, 52, 15, 666, 0, 657, 31, 657, 17, 48], ["+", 0, 52, 15, 666, 0, 657, 31, 657, 12, 612], ["+", 8, 196, 0, 52, 15, 666, 0, 657, 17, 72], ["+", 8, 196, 0, 52, 15, 666, 0, 657, 12, 612]] | 5 | 253 | 4 |
import sys
import math
from collections import deque
def insertion_sort(a, n, g):
ct = 0
for i in range(g,n):
v = a[i]
j = i-g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j-g
ct += 1
a[j+g] = v
return ct
n = int(input())
a = list(map(int... | import sys
import math
from collections import deque
def insertion_sort(a, n, g):
ct = 0
for i in range(g,n):
v = a[i]
j = i-g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j-g
ct += 1
a[j+g] = v
return ct
n = int(input())
a = list(map(int... | [["+", 3, 4, 0, 658, 0, 659, 12, 634, 0, 612], ["+", 3, 4, 0, 658, 0, 659, 12, 634, 0, 21], ["-", 3, 4, 0, 658, 0, 678, 0, 666, 667, 18], ["+", 3, 4, 0, 658, 0, 678, 0, 666, 667, 19]] | 5 | 217 | 4 |
import sys
import math
ct= 0
def insertion_sort(a, n, g):
for j in range(0,n-g):
v = a[j+g]
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j-g
ct += 1
a[j+g] = v
n = int(input())
a = list(map(int, sys.stdin.readlines()))
b = 701
g = [x for x in [1,4,10,23,... | import sys
import math
ct= 0
def insertion_sort(a, n, g):
global ct
for j in range(0,n-g):
v = a[j+g]
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j-g
ct += 1
a[j+g] = v
n = int(input())
a = list(map(int, sys.stdin.readlines()))
b = 701
g = [x for x ... | [["+", 0, 656, 0, 14, 8, 196, 0, 299, 0, 636], ["+", 0, 656, 0, 14, 8, 196, 0, 299, 0, 22]] | 5 | 213 | 31 |
cnt = 0
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i-g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
def shellSort(A, n):
G = [1]
while G[-1]*3+1 < n:
G.append(G[-1]*3 + 1)... | cnt = 0
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i-g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
def shellSort(A, n):
G = [1]
while G[-1]*3+1 < n:
G.append(G[-1]*3 + 1)... | [["+", 0, 1, 0, 662, 12, 658, 8, 652, 63, 22], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 24], ["+", 8, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 212 | 3 |
#Shell sort
def insertionSort(A, n, g, count):
Acopy = A.copy()
for i in range(g, n):
v = Acopy[i]
j = i - g
while (j >= 0) and (Acopy[j] > v):
Acopy[j + g] = Acopy[j]
j = j - g
count += 1
Acopy[j + g] = v
return Acopy, count
def shellSort... | def insertionSort(A, n, g, count):
Acopy = A.copy()
for i in range(g, n):
v = Acopy[i]
j = i - g
while (j >= 0) and (Acopy[j] > v):
Acopy[j + g] = Acopy[j]
j = j - g
count += 1
Acopy[j + g] = v
return Acopy, count
def shellSort(A, n):
... | [["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 612], ["-", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 12, 612], ["-", 0, 14, 8, 196, 0, 37, 0, 432, 0, 22], ["+", 0, 14, 8, 196, 0, 37, 0, 432, 0, 22]] | 5 | 268 | 5 |
def insertion_sort(a, g, cnt):
for i in range(g, len(a)):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] = v
return cnt
n = int(input())
g = [1]
t = 1
cnt = 0
while 1:
t = 3 * t + 1
if t < n // 9 and len(g) < 100:
g += [t]
else:
... | def insertion_sort(a, g, cnt):
for i in range(g, len(a)):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] = v
return cnt
n = int(input())
g = [1]
t = 1
cnt = 0
while 1:
t = 3 * t + 1
if t < n and len(g) < 100:
g += [t]
else:
g = ... | [["-", 0, 57, 15, 679, 31, 666, 0, 657, 17, 676], ["-", 0, 57, 15, 679, 31, 666, 0, 657, 12, 612]] | 5 | 203 | 2 |
#coding:utf-8
n = int(input())
A = [int(input()) for i in range(n)]
def insertionSort(A,n,g):
cnt = 0
for i in range(g,n,g):
v = A[i]
j = i - g
while j >= 0 and v < A[j]:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
return cnt
def shellSort(A,... | #coding:utf-8
n = int(input())
A = [int(input()) for i in range(n)]
def insertionSort(A,n,g):
cnt = 0
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and v < A[j]:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
return cnt
def shellSort... | [["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 226 | 2 |
def main():
n = int(input())
numbers = [input() for i in range(n)]
count = shellSort(numbers, n)
print(count)
[print(i) for i in numbers]
def shellSort(numbers, n):
count = 0
m = 1
g = []
while m < n :
g.append(m)
m = 3 * m + 1
g.reverse()
for h in g:
... | def main():
n = int(input())
numbers = [int(input()) for i in range(n)]
count = shellSort(numbers, n)
print(count)
[print(i) for i in numbers]
def shellSort(numbers, n):
count = 0
m = 1
g = []
while m <= n :
g.append(m)
m = 3 * m + 1
g.reverse()
for h in g:
... | [["+", 0, 1, 0, 662, 12, 658, 8, 652, 63, 22], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 52, 15, 666, 667, 18], ["+", 0, 14, 8, 196, 0, 52, 15, 666, 667, 19]] | 5 | 219 | 5 |
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
typedef struct pp {
char name[100];
int t;
} P;
queue<P> m;
int main() {
int i, n, q, ans = 0;
P u;
cin >> n >> q;
for (i = 0; i < n; i++) {
cin >> u.name >> u.t;
m.push(u);
}
while (!m.empty()) {
u = m.front();
... | #include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
typedef struct pp {
char name[100];
int t;
} P;
queue<P> m;
int main() {
int i, n, q, ans = 0;
P u;
cin >> n >> q;
for (i = 0; i < n; i++) {
cin >> u.name >> u.t;
m.push(u);
}
while (!m.empty()) {
u = m.front();
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 174 | 2 |
#include <deque>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main() {
int n, q;
deque<int> myque;
deque<string> nque;
string name;
long int time;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> name >> time;
nque.push_back(name);
my... | #include <deque>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main() {
int n, q;
deque<long int> myque;
deque<string> nque;
string name;
long int time;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> name >> time;
nque.push_back(name);
... | [["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 210 | 7 |
#include <iostream>
#include <queue>
using namespace std;
int main(void) {
int n, q, s;
cin >> n >> q;
string m;
queue<string> name;
queue<int> time;
for (int i = 0; i < n; i++) {
cin >> m >> s;
name.push(m);
time.push(s);
}
int t = 0;
while (!name.empty()) {
string a = name.front();
... | #include <iostream>
#include <queue>
using namespace std;
int main(void) {
int n, q, s;
cin >> n >> q;
string m;
queue<string> name;
queue<int> time;
for (int i = 0; i < n; i++) {
cin >> m >> s;
name.push(m);
time.push(s);
}
int t = 0;
while (!name.empty()) {
string a = name.front();
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]] | 1 | 187 | 2 |
#include <iostream>
#include <stdio.h>
#define LEN 100005
using namespace std;
struct Process {
char name[10];
int time;
};
int head, tail;
Process P[LEN];
bool isEmpty(void) { return head == tail; }
// bool isFull(void) {
// return
//}
Process deque(void) {
Process x = P[head];
head++;
if (head == LEN)... | #include <iostream>
#include <stdio.h>
#define LEN 100005
using namespace std;
struct Process {
char name[10];
int time;
};
int head, tail;
Process P[LEN];
bool isEmpty(void) { return head == tail; }
// bool isFull(void) {
// return
//}
Process deque(void) {
Process x = P[head];
head++;
if (head == LEN)... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 263 | 6 |
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
int n, q, t;
string name;
queue<pair<string, int>> Q;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> name >> t;
Q.push(make_pair(name, t));
}
pair<string, int> u;
int elaps = 0,... | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
//#include<stdlib.h>
using namespace std;
int main() {
int n, q, t;
string name;
queue<pair<string, int>> Q;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> name >> t;
Q.push(make_pair(name, t));
}
pair<string, int... | [["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 16, 17, 151]] | 1 | 177 | 2 |
#include <stdio.h>
#include <string.h>
#define LEN 100005 // プロセスの制約 100000 のため
// 構造体
// P という別名をつけている
typedef struct pp {
char name[100];
int t;
} P;
P Q[LEN]; // P structの配列
int head, tail, n; // head ... 先頭ポインタ, tail ... 末尾ポインタ
void enqueue(P x) {
Q[tail] = x;
tail = (tail + 1) % LEN;
}
P deque... | #include <stdio.h>
#include <string.h>
#define LEN 100005 // プロセスの制約 100000 のため
// 構造体
// P という別名をつけている
typedef struct pp {
char name[100];
int t;
} P;
P Q[LEN]; // P structの配列
int head, tail, n; // head ... 先頭ポインタ, tail ... 末尾ポインタ
void enqueue(P x) {
Q[tail] = x;
tail = (tail + 1) % LEN;
}
P deque... | [["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]] | 1 | 270 | 2 |
#include <iostream>
#include <string>
using namespace std;
class Process {
private:
string name;
int time;
public:
Process() = default;
Process(string name, int time) {
this->name = name;
this->time = time;
}
string getName() { return this->name; }
int getTime() { return this->time; }
void se... | #include <iostream>
#include <string>
using namespace std;
class Process {
private:
string name;
int time;
public:
Process() = default;
Process(string name, int time) {
this->name = name;
this->time = time;
}
string getName() { return this->name; }
int getTime() { return this->time; }
void se... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]] | 1 | 333 | 2 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <limits.h>
#include <queue>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define maxn 10000000
#define pi acos(-1)
using namespace std;
struct node {
char x[17];
int time;
} a[100007];
int main() {
que... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <limits.h>
#include <queue>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define maxn 10000000
#define pi acos(-1)
using namespace std;
struct node {
char x[17];
int time;
} a[100007];
int main() {
que... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 199 | 6 |
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
int n, q, t;
string name;
queue<pair<string, int>> Q;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> name >> t;
Q.push(make_pair(name, t));
}
pair<string, int> u;
int elaps = 0... | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
int n, q, t;
string name;
queue<pair<string, int>> Q;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> name >> t;
Q.push(make_pair(name, t));
}
pair<string, int> u;
int elaps = 0... | [["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]] | 1 | 173 | 4 |
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
#define LEN 100005
typedef struct pp {
char name[100];
int t;
} P;
P Q[LEN];
int head;
int tail;
int n;
// bool isEmpty()
// {
// return head == tail;
// }
// bool isFull()
// {
// return head == (tail + 1) % LEN;
// }
void enq... | #include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
#define LEN 100005
typedef struct pp {
char name[100];
int t;
} P;
P Q[LEN];
int head;
int tail;
int n;
// bool isEmpty()
// {
// return head == tail;
// }
// bool isFull()
// {
// return head == (tail + 1) % LEN;
// }
void enq... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 261 | 2 |
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
int n, q;
std::cin >> n >> q;
std::vector<std::string> names(n);
std::vector<int> times(n);
int val, buf, totalTime = 0;
for (int i = 0; i < n; ++i) {
std::cin >> names.at(i) >> val;
buf = std::min(q, val);
totalTime += bu... | #include <algorithm>
#include <iostream>
#include <vector>
int main() {
int n, q;
std::cin >> n >> q;
std::vector<std::string> names(n);
std::vector<int> times(n);
int val, buf, totalTime = 0;
for (int i = 0; i < n; ++i) {
std::cin >> names.at(i) >> val;
buf = std::min(q, val);
totalTime += bu... | [["-", 49, 50, 51, 2, 3, 4, 0, 27, 17, 29], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 9, 0, 52, 8, 9, 0, 1, 0, 35]] | 1 | 324 | 4 |
#include <iostream>
#include <queue>
using namespace std;
typedef struct {
string name;
int time;
} Process;
int main() {
int n, q;
queue<Process> que;
cin >> n >> q;
for (int i = 0; i < n; i++) {
string name;
int time;
cin >> name >> time;
Process p = {name, time};
que.push(p);
... | #include <iostream>
#include <queue>
using namespace std;
typedef struct {
string name;
int time;
} Process;
int main() {
int n, q;
queue<Process> que;
cin >> n >> q;
for (int i = 0; i < n; i++) {
string name;
int time;
cin >> name >> time;
Process p = {name, time};
que.push(p);
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 171 | 6 |
#include <iostream>
#include <string>
using namespace std;
struct elem {
string name;
int time;
};
template <class T> class Queue {
public:
Queue(int n) : xs{new T[n]}, maxsize{n}, head{}, tail{1} {};
void enqueue(T v) { xs[tail++] = v; };
T dequeue() { return xs[head++]; };
int begin() { return head; };... | #include <iostream>
#include <string>
using namespace std;
struct elem {
string name;
int time;
};
template <class T> class Queue {
public:
Queue(int n) : xs{new T[n]}, maxsize{n}, head{}, tail{0} {};
void enqueue(T v) { xs[tail++] = v; };
T dequeue() { return xs[head++]; };
int begin() { return head; };... | [["-", 0, 14, 0, 357, 0, 358, 0, 83, 0, 13], ["+", 0, 14, 0, 357, 0, 358, 0, 83, 0, 13]] | 1 | 318 | 2 |
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
struct process {
char name[11];
int time;
process(char *n, int t) {
strcpy(name, n);
time = t;
}
};
int main() {
char nm[11];
int i, n, t, q, t_elapsed = 0;
int *tp;
queue<process> prcs;
cin >> n >> q;
for (i = 0;... | #include <cstring>
#include <iostream>
#include <queue>
using namespace std;
struct process {
char name[11];
int time;
process(char *n, int t) {
strcpy(name, n);
time = t;
}
};
int main() {
char nm[11];
int i, n, t, q, t_elapsed = 0;
int *tp;
queue<process> prcs;
cin >> n >> q;
for (i = 0;... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 214 | 2 |
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define vvi vector<vector<int>>
#define All(X) X.begin(), X.end()
#define FOR... | #include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define vvi vector<vector<int>>
#define All(X) X.begin(), X.end()
#define FOR... | [["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]] | 1 | 264 | 4 |
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
struct PAIR {
string first;
int second;
};
int main() {
int number;
scanf("%d", &number);
int qu;
scanf("%d", &qu);
queue<PAIR> Q;
string name;
int ... | #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
struct PAIR {
string first;
int second;
};
int main() {
int number;
scanf("%d", &number);
int qu;
scanf("%d", &qu);
queue<PAIR> Q;
string name;
int ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 229 | 6 |
#include <iostream>
#include <queue>
using namespace std;
int main() {
int n, q;
int time = 0;
queue<int> Q, Qout;
queue<string> P, Pout;
cin >> n;
cin >> q;
while (n > 0) {
string N;
int T;
cin >> N;
cin >> T;
P.push(N);
Q.push(T);
n--;
}
while (!P.empty()) {
int T;
... | #include <iostream>
#include <queue>
using namespace std;
int main() {
int n, q;
int time = 0;
queue<int> Q, Qout;
queue<string> P, Pout;
cin >> n;
cin >> q;
while (n > 0) {
string N;
int T;
cin >> N;
cin >> T;
P.push(N);
Q.push(T);
n--;
}
while (!P.empty()) {
int T;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 184 | 6 |
#include <iostream>
#include <string>
using namespace std;
struct queue {
string name;
int time;
};
int tail, head;
queue Q[100000];
void enqueue(queue x);
queue dequeue();
int main() {
int n, q, t = 0, sum = -1;
string str;
cin >> n >> q;
tail = n;
head = 0;
for (int i = 0; i < n; i++)
cin >> Q... | #include <iostream>
#include <string>
using namespace std;
struct queue {
string name;
int time;
};
int tail, head;
queue Q[1000000];
void enqueue(queue x);
queue dequeue();
int main() {
int n, q, t = 0, sum = 0;
string str;
cin >> n >> q;
tail = n;
head = 0;
for (int i = 0; i < n; i++)
cin >> Q... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 11, 31, 69, 341, 342, 0, 27, 17, 29], ["+", 0, 11, 31, 69, 341, 342, 0, 27, 17, 29]] | 1 | 226 | 6 |
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;
queue<pair<string, int>> tasks;
int main() {
cin.tie(0);
ios::ios_base::sync_with_stdio(false);
int taskam, q, time = 0;
cin >> taskam >> q;
for (int i = 0; i < taskam; ++i) {
string name... | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;
queue<pair<string, int>> tasks;
int main() {
cin.tie(0);
ios::ios_base::sync_with_stdio(false);
int taskam, q, time = 0;
cin >> taskam >> q;
for (int i = 0; i < taskam; ++i) {
string name... | [["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]] | 1 | 219 | 4 |
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
queue<pair<string, int>> que;
for (int i = 0; i < n; ++i) {
string s;
int t;
cin >> s >> t;
que.push(make_pair(s, t));
}
int sum = 0;
while (que.size()) {... | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
queue<pair<string, int>> que;
for (int i = 0; i < n; ++i) {
string s;
int t;
cin >> s >> t;
que.push(make_pair(s, t));
}
int sum = 0;
while (que.size()) {... | [["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22]] | 1 | 162 | 2 |
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
int n, q; // n:number of process, q:quantum
int timer = 0;
queue<string> name;
queue<int> time;
cin >> n >> q;
for (int i = 0; i < n; ++i) {
string bufn;
int buft;
cin >> bufn >> buft;
name.push(bufn);
... | #include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
int n, q; // n:number of process, q:quantum
int timer = 0;
queue<string> name;
queue<int> time;
cin >> n >> q;
for (int i = 0; i < n; ++i) {
string bufn;
int buft;
cin >> bufn >> buft;
name.push(bufn);
... | [["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 189 | 4 |
#include <iostream>
#include <list>
#include <string>
using namespace std;
class Task {
public:
void input() { cin >> name >> time; }
string name;
int time;
};
int main() {
int n, q;
list<Task> tasks;
cin >> n >> q;
for (int i = 0; i < n; i++) {
auto task = Task();
task.input();
tasks.push_... | #include <iostream>
#include <list>
#include <string>
using namespace std;
class Task {
public:
void input() { cin >> name >> time; }
string name;
int time;
};
int main() {
int n, q;
list<Task> tasks;
cin >> n >> q;
for (int i = 0; i < n; i++) {
auto task = Task();
task.input();
tasks.push_... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 192 | 6 |
#include <iostream>
#include <queue>
#include <string>
using namespace std;
struct Process {
string name;
long t;
};
int main() {
queue<Process> qu;
long n, q;
cin >> n >> q;
for (long i = 0; i < n; i++) {
string name;
long t;
cin >> name >> t;
Process p;
p.name = name;
p.t = t;
... | #include <iostream>
#include <queue>
#include <string>
using namespace std;
struct Process {
string name;
long t;
};
int main() {
queue<Process> qu;
long n, q;
cin >> n >> q;
for (long i = 0; i < n; i++) {
string name;
long t;
cin >> name >> t;
Process p;
p.name = name;
p.t = t;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 187 | 6 |
#include <cstdio>
#include <iostream>
#include <string>
#define len 150000;
using namespace std;
struct A {
char name[100];
int time;
};
int head, tail, N, interval;
A a[1000];
A dequeue() {
A x = a[head++];
head = head % len;
return x;
}
void enqueue(A m) {
a[tail] = m;
tail = (tail + 1) % len;
}
i... | #include <cstdio>
#include <iostream>
#include <string>
#define len 150000
using namespace std;
struct A {
char name[100];
int time;
};
int head, tail, N, interval;
A a[len];
A dequeue() {
A x = a[head++];
head = head % len;
return x;
}
void enqueue(A m) {
a[tail] = m;
tail = (tail + 1) % len;
}
int... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 22]] | 1 | 235 | 4 |
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <string>
#define Lens 105
#define Nil -1
using namespace std;
struct work {
string s;
int key;
};
int N, limit;
queue<work> Q;
int main() {
cin >> N >> limit;
for (int i = 0; i < N; i++) ... | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdlib.h>
#include <string>
#define Lens 105
#define Nil -1
using namespace std;
struct work {
string s;
int key;
};
int N, limit;
queue<work> Q;
int main() {
cin >> N >> limit;
for (int i = 0; i < N; i++) ... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 180 | 6 |
#include <iostream>
#include <string>
#include <vector>
struct Que {
int head, tail;
std::vector<int> time;
std::vector<std::string> name;
};
int initialize(Que &q, int n) {
int qt;
std::cin >> qt;
for (int i = 0; i < n; i++) {
int time;
std::string name;
std::cin >> name;
std::cin >> time... | #include <iostream>
#include <string>
#include <vector>
struct Que {
int head, tail;
std::vector<int> time;
std::vector<std::string> name;
};
int initialize(Que &q, int n) {
int qt;
std::cin >> qt;
for (int i = 0; i < n; i++) {
int time;
std::string name;
std::cin >> name;
std::cin >> time... | [["-", 341, 342, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 341, 342, 0, 16, 12, 23, 0, 16, 12, 13]] | 1 | 394 | 10 |
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;
struct task {
string name;
int time;
};
int main() {
queue<task> que;
task t, t1;
string name;
int n, q, time, cnt_time;
cnt_time = 0;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> name >> time;
... | #include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;
struct task {
string name;
int time;
};
int main() {
queue<task> que;
task t, t1;
string name;
int n, q, time, cnt_time;
cnt_time = 0;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> name >> time;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 196 | 2 |
#include <iostream>
#include <queue>
#include <string>
using std::begin;
using std::end;
int main() {
int n, q;
std::cin >> n >> q;
std::queue<std::pair<std::string, int>> queue;
for (int i{0}; i < n; ++i) {
std::string name;
int t;
std::cin >> name >> t;
queue.emplace(name, t);
}
int tim... | #include <iostream>
#include <queue>
#include <string>
using std::begin;
using std::end;
int main() {
int n, q;
std::cin >> n >> q;
std::queue<std::pair<std::string, int>> queue;
for (int i{0}; i < n; ++i) {
std::string name;
int t;
std::cin >> name >> t;
queue.emplace(name, t);
}
int tim... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]] | 1 | 185 | 2 |
#include <cstdio>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
using namespace std;
const int N_MAX = 1000000;
void round_robin_scheduling(queue<pair<string, int>> q, int quantum) {
int cur_time = 0;
pair<string, int> p_i;
while (!q.empty()) {
p_i = q.front();... | #include <cstdio>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
using namespace std;
const int N_MAX = 1000000;
void round_robin_scheduling(queue<pair<string, int>> q, int quantum) {
int cur_time = 0;
pair<string, int> p_i;
while (!q.empty()) {
p_i = q.front();... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 215 | 2 |
#include <bits/stdc++.h>
#include <queue>
using namespace std;
struct process {
int time;
string name;
};
using namespace std;
int main() {
queue<struct process> a;
int num, limit, time = 0;
cin >> num >> limit;
struct process n, m;
for (int i = 0; i < num; i++) {
cin >> n.name >> n.time;
a.push(... | #include <bits/stdc++.h>
#include <queue>
using namespace std;
struct process {
int time;
string name;
};
using namespace std;
int main() {
queue<struct process> a;
int num, limit, time = 0;
cin >> num >> limit;
struct process n, m;
for (int i = 0; i < num; i++) {
cin >> n.name >> n.time;
a.push(... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]] | 1 | 190 | 2 |
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
typedef struct _q {
string name;
int time;
} que;
int n;
int head = 1, tail;
que qar[100003];
void enq(que q) {
if (tail < n + 2)
tail++;
else
tail ... | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
typedef struct _q {
string name;
int time;
} que;
int n;
int head = 1, tail;
que qar[100003];
void enq(que q) {
if (tail < n + 2)
tail++;
else
tail ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 271 | 6 |
#include <iostream>
#include <string>
#include <vector>
struct task {
int idx;
int next;
int prev;
std::string name;
int time;
};
int main() {
int n, q;
int time = 0;
int done = 0;
task queue[100000];
// input
std::ios::sync_with_stdio(false);
std::cin >> n >> q;
// make queue
queue[0].p... | #include <iostream>
#include <string>
#include <vector>
struct task {
int idx;
int next;
int prev;
std::string name;
int time;
};
int main() {
int n, q;
int time = 0;
int done = 0;
task queue[100000];
// input
std::ios::sync_with_stdio(false);
std::cin >> n >> q;
// make queue
queue[0].p... | [["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 296 | 2 |
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
struct node {
string name;
int time;
};
queue<node> Q;
int main() {
int n, q;
scanf("%d %d", &n, &q);
node ns;
for (int i = 0; i < n; i++) {
cin >> ns.name >> ns.time;
Q.push(ns);
... | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
struct node {
string name;
int time;
};
queue<node> Q;
int main() {
int n, q;
scanf("%d %d", &n, &q);
node ns;
for (int i = 0; i < n; i++) {
cin >> ns.name >> ns.time;
Q.push(ns);
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 202 | 6 |
#include <cstdlib>
#include <iostream>
#include <string>
#define N 1000
using namespace std;
class Queue {
private:
int num[N];
int head;
int tail;
public:
Queue() {
head = 0;
tail = 0;
}
// add to head position
void push(int x) {
num[tail] = x;
tail++;
}
// delete head position
... | #include <cstdlib>
#include <iostream>
#include <string>
#define N 100000
using namespace std;
class Queue {
private:
int num[N];
int head;
int tail;
public:
Queue() {
head = 0;
tail = 0;
}
// add to head position
void push(int x) {
num[tail] = x;
tail++;
}
// delete head position
... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]] | 1 | 381 | 2 |
#include <iostream>
#include <queue>
using namespace std;
class State {
public:
string s;
int rem;
State() {}
State(string s, int rem) : s(s), rem(rem) {}
};
int main() {
int n, q;
queue<State> que;
while (cin >> n >> q) {
for (int i = 0; i < n; i++) {
string name;
int rem;
cin >... | #include <iostream>
#include <queue>
using namespace std;
class State {
public:
string s;
int rem;
State() {}
State(string s, int rem) : s(s), rem(rem) {}
};
int main() {
int n, q;
queue<State> que;
while (cin >> n >> q) {
for (int i = 0; i < n; i++) {
string name;
int rem;
cin >... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 194 | 6 |
#include <iostream>
#include <queue>
#include <string> //これがないと、cinでstring型が使えないという謎発見
using namespace std;
//わざわざクラス作るの大変なので構造体(別のファイルにできないし)
// using namespace std; よりも前に書いちゃうと、stringとかにstd::string
// とかわざわざ指定しないと使えないので注意
typedef struct Process_temp {
int time_slot;
string quantum;
} Process;
int main() {
in... | #include <iostream>
#include <queue>
#include <string> //これがないと、cinでstring型が使えないという謎発見
using namespace std;
//わざわざクラス作るの大変なので構造体(別のファイルにできないし)
// using namespace std; よりも前に書いちゃうと、stringとかにstd::string
// とかわざわざ指定しないと使えないので注意
typedef struct Process_temp {
int time_slot;
string quantum;
} Process;
int main() {
in... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 214 | 2 |
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;
int main(void) {
int n, q;
int inp;
string inp2;
queue<pair<string, int>> pro;
int now = 0;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> inp2 >> inp;
pro.push(pair<string, i... | #include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;
int main(void) {
int n, q;
int inp;
string inp2;
queue<pair<string, int>> pro;
int now = 0;
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> inp2 >> inp;
pro.push(pair<string, i... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]] | 1 | 210 | 2 |
#include <iostream>
#define SIZE 200000
using namespace std;
struct Queue {
int table[SIZE];
int tail, head;
void init() { head = tail = 0; }
bool empty() { return head == tail; }
void inqueue(int x) {
table[tail] = x;
tail++;
tail %= SIZE;
}
int dequeue() {
if (empty())
return ... | #include <iostream>
#define SIZE 200000
using namespace std;
struct Queue {
int table[SIZE];
int tail, head;
void init() { head = tail = 0; }
bool empty() { return head == tail; }
void inqueue(int x) {
table[tail] = x;
tail++;
tail %= SIZE;
}
int dequeue() {
if (empty())
return ... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22]] | 1 | 275 | 6 |
import queue
procs = queue.Queue()
n,q = list(map(int,input().split()))
for i in range(n):
name,time = input().split()
procs.put((name,int(time)))
time=0
doneprocs = queue.Queue()
while True:
if procs.empty():
break
temp = procs.get()
if temp[1] < q:
time += temp[1]
donepro... | import queue
procs = queue.Queue()
n,q = list(map(int,input().split()))
for i in range(n):
name,time = input().split()
procs.put((name,int(time)))
time=0
doneprocs = queue.Queue()
while True:
if procs.empty():
break
temp = procs.get()
if temp[1] <= q:
time += temp[1]
donepr... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19]] | 5 | 165 | 2 |
from collections import deque
n,q=[int(i) for i in input().split()]
name=[0 for i in range(n)]
time=[0 for i in range(n)]
answer_name=[]
answer_time=[]
total_time=0
for i in range(n):
name[i],time[i]=input().split()
d_name = deque(name)
d_time = deque(time)
while len(d_name)>0:
a=d_name.popleft()
b=int... | from collections import deque
n,q=[int(i) for i in input().split()]
name=[0 for i in range(n)]
time=[0 for i in range(n)]
answer_name=[]
answer_time=[]
total_time=0
for i in range(n):
name[i],time[i]=input().split()
d_name = deque(name)
d_time = deque(time)
while len(d_name)>0:
a=d_name.popleft()
b=int... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22]] | 5 | 187 | 6 |
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.po... | 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.po... | [["-", 0, 1, 0, 652, 3, 4, 0, 660, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 660, 0, 25]] | 5 | 180 | 2 |
import queue
q = queue.Queue()
exetime = 0
n, quantum = map(int, input().split())
for i in range(n):
q.put(tuple(input().split())) # tupleで渡す
while not q.empty():
process = q.get()
#print(process)
time = int(process[1])
if time > 100:
exetime += 100
q.put((process[0], time - 100))
... | import queue
q = queue.Queue()
exetime = 0
n, quantum = map(int, input().split())
for i in range(n):
q.put(tuple(input().split())) # tupleで渡す
while not q.empty():
process = q.get()
#print(process)
time = int(process[1])
if time > quantum:
exetime += quantum
q.put((process[0], time ... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22], ["-", 0, 652, 3, 4, 0, 660, 0, 657, 12, 612], ["+", 0, 652, 3, 4, 0, 660, 0, 657, 12, 22]] | 5 | 114 | 6 |
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=0
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:
... | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]] | 5 | 176 | 3 |
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 18:04:22 2018
ALDS1_3b_r リングバッファによる実装
@author: maezawa
"""
def fifo_enque(data):
global tail
global fifo
fifo[tail] = data
tail = (tail+1)%fifo_size
def fifo_deque():
global head
global fifo
data = fifo[head]
head = (head+1)%fifo_si... | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 18:04:22 2018
ALDS1_3b_r リングバッファによる実装
@author: maezawa
"""
def fifo_enque(data):
global tail
global fifo
fifo[tail] = data
tail = (tail+1)%fifo_size
def fifo_deque():
global head
global fifo
data = fifo[head]
head = (head+1)%fifo_si... | [["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 228 | 2 |
a=input().split()
n=int(a[0])
q=int(a[1])
b=[0 for i in range(2*n)]
cnt=0
tmp=0
for i in range(n):
B=input().split()
b[2*i]=B[0]
b[2*i+1]=int(B[1])
while len(b)>0:
tmp=b[1]-100
if tmp>0:
b.append(b[0])
b.append(tmp)
del b[0]
del b[0]
cnt=cnt+100
else:
... | a=input().split()
n=(int)(a[0])
q=(int)(a[1])
b=[0 for i in range(2*n)]
cnt=0
tmp=0
for i in range(n):
B=input().split()
b[2*i]=B[0]
b[2*i+1]=int(B[1])
while len(b)>0:
tmp=b[1]-q
if tmp>0:
b.append(b[0])
b.append(tmp)
del b[0]
del b[0]
cnt=cnt+q
else:
... | [["+", 0, 1, 0, 662, 12, 652, 63, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 63, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22]] | 5 | 171 | 8 |
from collections import deque
n, q = [int(_) for _ in input().split()]
processes = deque([tuple(input().split()) for i in range(n)])
time = 0
while processes:
process = processes.popleft()
if int(process[1]) < q:
time += int(process[1])
print(process[0], time)
else:
time += q
... | from collections import deque
n, q = [int(_) for _ in input().split()]
processes = deque([tuple(input().split()) for i in range(n)])
time = 0
while processes:
process = processes.popleft()
if int(process[1]) <= q:
time += int(process[1])
print(process[0], time)
else:
time += q
... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19]] | 5 | 116 | 2 |
n, q = [int(i) for i in input().split()]
que = []
ans_count = 0 #出力数
time = 0 #経過時間
# data読み込み
for i in range(n):
que.append([i for i in input().split()])
while(ans_count!=n):
pop_process = que.pop(0)
pop_process[1] = int(pop_process[1])
# 末尾から追加、先頭から取り出す
if pop_process[1] < q:
time += pop_... | n, q = [int(i) for i in input().split()]
que = []
ans_count = 0 #出力数
time = 0 #経過時間
# data読み込み
for i in range(n):
que.append([i for i in input().split()])
while(ans_count!=n):
pop_process = que.pop(0)
pop_process[1] = int(pop_process[1])
# 末尾から追加、先頭から取り出す
if pop_process[1] <= q:
time += pop... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19]] | 5 | 137 | 2 |
# -*- coding: utf-8 -*-
def simu(pro, q):
end_time = 0
while bool(pro):
if pro[1] > q:
end_time += q
pro.append(pro[0])
pro.append(pro[1] - q)
pro.pop(0)
pro.pop(1)
elif pro[1] <= q:
end_time += pro[1]
print(... | # -*- coding: utf-8 -*-
def simu(pro, q):
end_time = 0
while bool(pro):
if pro[1] > q:
end_time += q
pro.append(pro[0])
pro.append(pro[1] - q)
pro.pop(0)
pro.pop(0)
elif pro[1] <= q:
end_time += pro[1]
print(... | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["-", 3, 4, 0, 652, 3, 4, 0, 206, 206, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 206, 206, 612]] | 5 | 169 | 6 |
import collections
n, q = list(map(int, input().split()))
datalist = [input().split() for i in range(n)]
datalist = collections.deque(datalist)
time = 0
while len(datalist):
data = datalist.popleft()
data[1] = int(data[1])
if data[1] <= 100:
time += data[1]
print(data[0], time)
else:
time += 100
dat... | import collections
n, q = list(map(int, input().split()))
datalist = [input().split() for i in range(n)]
datalist = collections.deque(datalist)
time = 0
while len(datalist):
data = datalist.popleft()
data[1] = int(data[1])
if data[1] <= q:
time += data[1]
print(data[0], time)
else:
time += q
data[1]... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 75, 76, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 12, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]] | 5 | 120 | 6 |
def roundRobin(q, process, time)
currentTime = 0
loop do
break if process.empty?
p = process.shift
t = time.shift
if t <= q
currentTime += t
puts p + " " + currentTime.to_s
else
t -= q
process.push p
time.push t
currentTime += q
end
end
end
if __FILE__... | def roundRobin(q, process, time)
currentTime = 0
loop do
break if process.empty?
p = process.shift
t = time.shift
if t <= q
currentTime += t
puts p + " " + currentTime.to_s
else
t -= q
process.push p
time.push t
currentTime += q
end
end
end
if __FILE__... | [["-", 0, 493, 0, 121, 64, 749, 0, 652, 735, 22], ["-", 0, 121, 64, 749, 0, 652, 3, 4, 0, 22]] | 4 | 120 | 2 |
class Task
def initialize(name, qms)
@name = name
if !qms.is_a? Integer
qms = qms.to_i
end
@qms = qms
end
def consume(time)
@qms -= time
end
def to_s
"#{@name}"
end
end
n, consume_time = STDIN.gets.split.map(&:to_i)
queue = []
n.times do
pname, ptime = STDIN.gets.split
queue.push(Task.new(p... | class Task
def initialize(name, qms)
@name = name
if !qms.is_a? Integer
qms = qms.to_i
end
@qms = qms
end
def consume(time)
@qms -= time
end
def to_s
"#{@name}"
end
end
n, consume_time = STDIN.gets.split.map(&:to_i)
queue = []
n.times do
pname, ptime = STDIN.gets.split
queue.push(Task.new(p... | [["-", 8, 170, 0, 121, 64, 749, 0, 755, 12, 612], ["+", 8, 170, 0, 121, 64, 749, 0, 755, 12, 22]] | 4 | 146 | 2 |
# queue.rb
s=STDIN.gets.split
n=s[0].to_i
q=s[1].to_i
queue=Array.new(n)
name =Array.new(n)
time =Array.new(n)
0.upto(n-1) {|i|
s=STDIN.gets.split
queue[i]=i
name[i]=s[0].to_s
time[i]=s[1].to_i
}
qp=0
elapsed=0
while (n>0) do
top=queue[qp]
if time[top] <= 100 then
elapsed += time[top]
printf("%s %... | # queue.rb
s=STDIN.gets.split
n=s[0].to_i
q=s[1].to_i
queue=Array.new(n)
name =Array.new(n)
time =Array.new(n)
0.upto(n-1) {|i|
s=STDIN.gets.split
queue[i]=i
name[i]=s[0].to_s
time[i]=s[1].to_i
}
qp=0
elapsed=0
while (n>0) do
top=queue[qp]
if time[top] <= q then
elapsed += time[top]
printf("%s %d\... | [["-", 0, 89, 8, 170, 0, 121, 15, 738, 12, 612], ["+", 0, 89, 8, 170, 0, 121, 15, 738, 12, 22], ["-", 8, 170, 0, 121, 75, 95, 0, 755, 12, 612], ["+", 8, 170, 0, 121, 75, 95, 0, 755, 12, 22]] | 4 | 164 | 6 |
n, q = gets.chomp.split.map(&:to_i)
queue = Array.new
5.times do |i|
input = gets.chomp.split
name = input[0]
time = input[1].to_i
queue.push [name, time]
end
flag = true
time = 0
while flag
diff = queue[0][1] - q
name = queue[0][0]
if diff > 0
queue.shift
queue.push [name, diff]... | n, q = gets.chomp.split.map(&:to_i)
queue = Array.new
n.times do |i|
input = gets.chomp.split
name = input[0]
time = input[1].to_i
queue.push [name, time]
end
flag = true
time = 0
while flag
diff = queue[0][1] - q
name = queue[0][0]
if diff > 0
queue.shift
queue.push [name, diff]... | [["-", 36, 36, 36, 36, 0, 493, 0, 652, 486, 612], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 486, 22]] | 4 | 143 | 2 |
line1 = STDIN.gets.chomp.split(" ")
n = line1[0].to_i
q = line1[1].to_i
queue = Array.new(n)
n.times do |i|
line = STDIN.gets.chomp.split(" ")
process = [line[0], line[1].to_i]
queue[i] = process
end
time = 0
processes_ended = Array.new
while queue.empty? == false
process = queue.shift
if process[1] > q
... | line1 = STDIN.gets.chomp.split(" ")
n = line1[0].to_i
q = line1[1].to_i
queue = Array.new(n)
n.times do |i|
line = STDIN.gets.chomp.split(" ")
process = [line[0], line[1].to_i]
queue[i] = process
end
time = 0
processes_ended = Array.new
while queue.empty? == false
process = queue.shift
if process[1] > q
... | [["-", 0, 121, 75, 95, 0, 755, 12, 652, 17, 131], ["-", 0, 121, 75, 95, 0, 755, 12, 652, 735, 22], ["+", 0, 121, 75, 95, 0, 755, 12, 742, 0, 70], ["+", 0, 121, 75, 95, 0, 755, 12, 742, 0, 612], ["+", 0, 121, 75, 95, 0, 755, 12, 742, 0, 73]] | 4 | 151 | 10 |
n,q = gets.split.map(&:to_i)
queue = []
n.times{
queue << gets.split
}
# n,q=5,100
# queue = [["p1",150],["p2",80],["p3",200],["p4",350],["p5",20]]
# time = 0
def aqueue(n,q,queue,time)
ans = []
while queue.size != 0
v = queue.shift
if v[1].to_i <= q
time += v[1].to_i
ans.push("#{v[0]} #{time}... | n,q = gets.split.map(&:to_i)
queue = []
n.times{
queue << gets.split
}
# n,q=5,100
# queue = [["p1",150],["p2",80],["p3",200],["p4",350],["p5",20]]
time = 0
def aqueue(n,q,queue,time)
ans = []
while queue.size != 0
v = queue.shift
if v[1].to_i <= q
time += v[1].to_i
ans.push("#{v[0]} #{time}")... | [["+", 36, 36, 36, 36, 0, 493, 0, 662, 31, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 0, 32], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612]] | 4 | 129 | 3 |
n, q = gets.chomp.split(' ').map(&:to_i)
arr = []
(0...n).each do |i|
arr[i]= gets.chomp.split(' ')
end
class Queue
attr_accessor :head, :tail, :queue
def initialize(size)
@head = 0
@tail = 0
@queue = Array.new(size)
end
def enqueue(x)
@queue[@tail] = x
if @tail + 1 == @queue.size
... | n, q = gets.chomp.split(' ').map(&:to_i)
arr = []
(0...n).each do |i|
arr[i]= gets.chomp.split(' ')
end
class Queue
attr_accessor :head, :tail, :queue
def initialize(size)
@head = 0
@tail = 0
@queue = Array.new(size)
end
def enqueue(x)
@queue[@tail] = x
if @tail + 1 == @queue.size
... | [["-", 8, 170, 0, 121, 64, 749, 0, 755, 12, 612], ["+", 8, 170, 0, 121, 64, 749, 0, 755, 12, 22]] | 4 | 257 | 2 |
#ALDS_1_3_B Queue
input = IO
# input = DATA
procs = []
completed = []
qtime = 0
n,q = input.gets.chomp.split.map(&:to_i)
n.times do
name,time = input.gets.split
procs.push(Hash[name,time.to_i])
end
while(procs.any?) do
prok = procs.shift
v = prok.first[-1]
if (v > q) then
prok[prok.first[0]]= v - q
p... | #ALDS_1_3_B Queue
input = $stdin
# input = DATA
procs = []
completed = []
qtime = 0
n,q = input.gets.chomp.split.map(&:to_i)
n.times do
name,time = input.gets.split
procs.push(Hash[name,time.to_i])
end
while(procs.any?) do
prok = procs.shift
v = prok.first[-1]
if (v > q) then
prok[prok.first[0]]= v - q
... | [["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 743], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 12, 744]] | 4 | 132 | 7 |
class Proces
def initialize(name,time)
@name = name
@time = time.to_i
end
def act limit
if @time > limit
@time -= limit
true
end
false
end
attr_reader :name,:time
end
queue = Array.new()
time = 0
temp = gets.split(" ").map{|x| x.to_i}
q = temp.pop
num = temp.pop
num.times do
... | class Proces
def initialize(name,time)
@name = name
@time = time.to_i
end
def act limit
if @time > limit
@time -= limit
true
end
end
attr_reader :name,:time
end
queue = Array.new()
time = 0
temp = gets.split(" ").map{|x| x.to_i}
q = temp.pop
num = temp.pop
num.times do
temp = ge... | [["-", 0, 269, 8, 736, 0, 735, 8, 736, 0, 147]] | 4 | 162 | 1 |
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'... | class a(object):
def __init__(self, buf_size=10000000):
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 emp... | [["-", 8, 196, 0, 14, 54, 54, 0, 696, 51, 612], ["+", 8, 196, 0, 14, 54, 54, 0, 696, 51, 612], ["-", 0, 14, 8, 196, 0, 37, 0, 666, 0, 697], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 238 | 4 |
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]
... | 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(0)
if(current[1] > q):
current[1] -= q
a.append(current)
total_time += q
else:
total_time += current[1]
... | [["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 116 | 3 |
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(se... | class queue():
def __init__(self):
self.head = 0
self.tail = 0
self.MAX = 100000
self.Q = [[0] for i in range(self.MAX)]
def is_empty(self):
return self.head == self.tail
def is_full(self):
return self.head == (self.tail + 1) % self.MAX
def enqueue(self... | [["-", 0, 659, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22]] | 5 | 366 | 4 |
n,q = map(int,input().split())
A = [list(map(str,input().split())) for i in range(n)]
time = 0
flag = 1
while len(A) > 0:
if int(A[0][1]) <= q: #プロセスが完了する場合
time += int(A[0][1])
print(A[0][1],time)
del A[0]
else: #プロセスが完了しない場合
time += q
A[0][1] = str(int(A[0][1])-q)
... | n,q = map(int,input().split())
A = [list(map(str,input().split())) for i in range(n)]
time = 0
flag = 1
while len(A) > 0:
if int(A[0][1]) <= q: #プロセスが完了する場合
time += int(A[0][1])
print(A[0][0],time)
del A[0]
else: #プロセスが完了しない場合
time += q
A[0][1] = str(int(A[0][1])-q)
... | [["-", 0, 1, 0, 652, 3, 4, 0, 206, 206, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 612]] | 5 | 143 | 2 |
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)
| 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)
| [["-", 0, 1, 0, 652, 3, 4, 0, 660, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 634, 0, 70], ["-", 3, 4, 0, 660, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 652, 3, 4, 0, 634, 0, 73]] | 5 | 118 | 4 |
pnum,mtime = map(int,input().split(" "))
total = [list(input().split(" ")) for _ in range(pnum)]
print(total)
cnt=0
tcnt=0
while len(total) > 0:
ztime = int(total[0][1]) - mtime
if ztime <= 0:
tcnt += int(total[0][1])
print(total[0][0],int(tcnt))
total.pop(0)
else:
total.append([total[0][0],ztime])
tota... |
pnum,mtime = map(int,input().split(" "))
total = [list(input().split(" ")) for _ in range(pnum)]
cnt=0
tcnt=0
while len(total) > 0:
ztime = int(total[0][1]) - mtime
if ztime <= 0:
tcnt += int(total[0][1])
print(total[0][0],int(tcnt))
total.pop(0)
else:
total.append([total[0][0],ztime])
total.pop(0)
tc... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 143 | 4 |
from collections import deque
if __name__ == "__main__":
n, q = input().split()
n, q = int(n), int(q)
s = 0
a = deque([list(map(str,input().split())) for _ in range(n)])
while len(a):
x = a.popleft()
if int(x[1]) < q:
s += int(x[1])
print(x[0],s)
els... | from collections import deque
if __name__ == "__main__":
n, q = input().split()
n, q = int(n), int(q)
s = 0
a = deque([list(map(str,input().split())) for _ in range(n)])
while len(a):
x = a.popleft()
if int(x[1]) - q <= 0:
s += int(x[1])
print(x[0], s)
... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612]] | 5 | 137 | 4 |
N_str, q_str = input().spilit()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0
for i in N:
t = 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 +=... | N_str, q_str = input().split()
N = int(N_str)
q = int(q_str)
A =[]
B =[]
total =0
for i in range(N):
t = 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
tota... | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25]] | 5 | 132 | 7 |
class Queue():
def __init__(self):
self.size = 0
self.Max = 100000
self.queue = [None]
def isEmpty(self):
return self.size == 0
def isFull(self):
return self.size >= self.Max
def enqueue(self, x):
if self.isFull():
print("Queue overflow!")
... | class Queue():
def __init__(self):
self.size = 0
self.Max = 100000
self.queue = [None]
def isEmpty(self):
return self.size == 0
def isFull(self):
return self.size >= self.Max
def enqueue(self, x):
if self.isFull():
print("Queue overflow!")
... | [["-", 0, 677, 12, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 677, 12, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 677, 12, 652, 3, 4, 0, 206, 206, 612], ["-", 0, 677, 12, 652, 3, 4, 0, 206, 0, 73], ["+", 0, 1, 0, 677, 12, 652, 3, 4, 0, 22]] | 5 | 262 | 27 |
class Queue(object):
def __init__(self, l):
self._queue = l
self._n = len(l)
self._head = 0
self._tail = 0
def pop_left(self):
if self._head == self._n:
self._head = 0
ret = self._queue[self._head][::]
self._head += 1
return ret
... | class Queue(object):
def __init__(self, l):
self._queue = l
self._n = len(l)
self._head = 0
self._tail = 0
def pop_left(self):
if self._head == self._n:
self._head = 0
ret = self._queue[self._head][::]
self._head += 1
return ret
... | [["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 260 | 4 |
# input
n, q = list(map(int, input().split()))
procs = [input().split() for i in range(n)]
procs = list(reversed(procs))
# procsessing
cnt, lack = 0, 1
while lack > 0:
lack = 0
tprocs = []
for i in range(n):
proc = procs.pop()
t = int(proc[1])
if t <= q:
cnt += t
... | # input
n, q = list(map(int, input().split()))
procs = [input().split() for i in range(n)]
procs = list(reversed(procs))
# procsessing
cnt, lack = 0, 1
while lack > 0:
lack = 0
tprocs = []
for i in range(n):
proc = procs.pop()
t = int(proc[1])
if t <= q:
cnt += t
... | [["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 143 | 6 |
# -*- coding: utf-8 -*-
def round_robin_scheduling(process_name, process_time, q):
result = []
elapsed_time = 0
while len(process_name) > 0:
if process_time[0] <= q:
elapsed_time += process_time[0]
process_time.pop(0)
result.append(process_name.pop(0) + ' ' + s... | # -*- coding: utf-8 -*-
def round_robin_scheduling(process_name, process_time, q):
result = []
elapsed_time = 0
while len(process_name) > 0:
# print process_name
# print process_time
if process_time[0] <= q:
elapsed_time += process_time[0]
process_time.pop(... | [["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 204 | 6 |
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 | 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 | [["-", 75, 76, 8, 196, 0, 1, 0, 677, 17, 110], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32]] | 5 | 121 | 2 |
n, q = map(int, input().split())
l = [list(input().split()) for i in range(n)]
from collections import deque
que = deque([[l[i][0], int(l[i][1])] for i in range(n)])
a = []
time = 0
while que != deque([]):
a = que.popleft()
if a[1] <= 100:
time += a[1]
print("{} {}".format(a[0], str(time)))
... | n, q = map(int, input().split())
l = [list(input().split()) for i in range(n)]
from collections import deque
que = deque([[l[i][0], int(l[i][1])] for i in range(n)])
a = []
time = 0
while que != deque([]):
a = que.popleft()
if a[1] <= q:
time += a[1]
print("{} {}".format(a[0], str(time)))
el... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 75, 76, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 12, 22], ["-", 0, 1, 0, 662, 12, 432, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 432, 0, 657, 12, 22]] | 5 | 163 | 6 |
import collections
import sys
n,q = map(int,input().split())
data = [[i for i in input().split()]for i in range(n)]
time = 0
while data:
task = data[0]
del data[0]
if int(task[1]) < q:
time += int(task[1])
print(task[0],time)
else:
time += q
task[1] = str(int(task... | import collections
import sys
n,q = map(int,input().split())
data = [[i for i in input().split()]for i in range(n)]
time = 0
while data:
task = data[0]
del data[0]
if int(task[1]) <= q:
time += int(task[1])
print(task[0],time)
else:
time += q
task[1] = str(int(tas... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19]] | 5 | 118 | 2 |
s = input().split()
n = int(s[0])
q = int(s[1])
process_name = []
process_time = []
for x in range(n):
ps = input().split()
process_name.append(ps[0])
process_time.append(int(ps[1]))
total_time = 0
while process_name != []:
pn = process_name.pop(0)
pt = process_time.pop(0)
if pt <= q:
total_time += pt... | s = input().split()
n = int(s[0])
q = int(s[1])
process_name = []
process_time = []
for x in range(n):
ps = input().split()
process_name.append(ps[0])
process_time.append(int(ps[1]))
total_time = 0
while process_name != []:
pn = process_name.pop(0)
pt = process_time.pop(0)
if pt <= q:
total_time += pt... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 135 | 4 |
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="... | 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=... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19]] | 5 | 185 | 2 |
#ALDS1_3-B Elementary data structures - Queue
n,q = [int(x) for x in input().split()]
Q=[]
for i in range(n):
Q.append(input().split())
t=0
res=[]
while Q!=[]:
if int(Q[0][1])<q:
res.append([Q[0][0],int(Q[0][1])+t])
t+=int(Q[0][1])
else:
Q.append([Q[0][0],int(Q[0][1])-q])
t+=... | #ALDS1_3-B Elementary data structures - Queue
n,q = [int(x) for x in input().split()]
Q=[]
for i in range(n):
Q.append(input().split())
t=0
res=[]
while Q!=[]:
if int(Q[0][1])<=q:
res.append([Q[0][0],int(Q[0][1])+t])
t+=int(Q[0][1])
else:
Q.append([Q[0][0],int(Q[0][1])-q])
t+... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19]] | 5 | 172 | 2 |
import queue
import sys
class Proc:
def __init__(self, name, time):
self.time = time
self.name = name
def main():
array = [int(x) for x in 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... | import queue
import sys
class Proc:
def __init__(self, name, time):
self.time = time
self.name = name
def main():
array = [int(x) for x in 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... | [["+", 63, 319, 500, 652, 63, 319, 500, 319, 319, 22], ["+", 500, 652, 63, 319, 500, 652, 63, 319, 0, 131]] | 5 | 203 | 2 |
class Queue():
def __init__(self):
self.el = []
def add(self, el):
self.el.append(el)
def delete(self):
return self.el.pop(0)
def action(self):
self.el[0]['time'] -= 100
tmp = self.delete()
self.el.append(tmp)
n, q = list(map(int, i... | class Queue():
def __init__(self):
self.el = []
def add(self, el):
self.el.append(el)
def delete(self):
return self.el.pop(0)
def action(self):
self.el[0]['time'] -= q
tmp = self.delete()
self.el.append(tmp)
n, q = list(map(int, inp... | [["-", 0, 14, 8, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 14, 8, 196, 0, 1, 0, 677, 12, 22]] | 5 | 217 | 2 |
process_num, qms = map(int, input().split())
raw_procs = [input() for i in range(process_num)]
if __name__ == '__main__':
procs = []
for row in raw_procs:
name, time = row.split()
procs.append({
"name": name,
"time": int(time),
})
total_time = 0
current... | process_num, qms = map(int, input().split())
raw_procs = [input() for i in range(process_num)]
if __name__ == '__main__':
procs = []
for row in raw_procs:
name, time = row.split()
procs.append({
"name": name,
"time": int(time),
})
total_time = 0
current... | [["-", 75, 76, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 667, 60], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]] | 5 | 198 | 4 |
n, q = map(int, input().split())
processes = []
for i in range(int(n)):
process_name, process_time = input().split()
processes.append([process_name, int(process_time)])
elapsed_time = 0
while len(processes):
process = processes.pop(0)
if process[1] > 100:
process[1] -= 100
processes.a... | n, q = map(int, input().split())
processes = []
for i in range(int(n)):
process_name, process_time = input().split()
processes.append([process_name, int(process_time)])
elapsed_time = 0
while len(processes):
process = processes.pop(0)
if process[1] > q:
process[1] -= q
processes.appen... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22]] | 5 | 112 | 6 |
class My_Queue:
def __init__(self, S):
self.S = S
self.q = [0 for i in range(S)]
self.head = 0
self.tail = 0
def enqueue(self, x):
if self.isFull():
print('overflow')
raise
else:
self.q[self.tail] = x
if self.tail... | class My_Queue:
def __init__(self, S):
self.S = S
self.q = [0 for i in range(S)]
self.head = 0
self.tail = 0
def enqueue(self, x):
if self.isFull():
print('overflow')
raise
else:
self.q[self.tail] = x
if self.tail... | [["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 341 | 6 |
from collections import deque
def round_robin_scheduling(N, Q, A):
t = 0
while A:
process = A.popleft()
if process[1] < Q:
t += process[1]
print(process[0],t)
else:
t += Q
A.append([process[0],process[1]-Q])
if __name__ == '__main__':
... | # encoding: utf-8
from collections import deque
def round_robin_scheduling(N, Q, A):
t = 0
while A:
process = A.popleft()
if process[1] <= Q:
t += process[1]
print(process[0],t)
else:
t += Q
A.append([process[0],process[1]-Q])
if __name_... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19]] | 5 | 149 | 2 |
ary=gets.chomp.split(" ")
stack=[]
c=[]
ary.each {|x|
if x =~ /\d+/
x=x.to_i
stack.unshift(x)
p stack
c=nil
elsif x== "+" || x=="-" || x=="*" || x=="/"
b=stack.shift
a=stack.shift
case x
when "+"
stack=stack.unshift(a+b)
when "-"
stack=stack.unshift(a-b)
when "*"
stack=stack.unsh... | ary=gets.chomp.split(" ")
stack=[]
c=[]
ary.each {|x|
if x =~ /\d+/
x=x.to_i
stack.unshift(x)
c=nil
elsif x== "+" || x=="-" || x=="*" || x=="/"
b=stack.shift
a=stack.shift
case x
when "+"
stack=stack.unshift(a+b)
when "-"
stack=stack.unshift(a-b)
when "*"
stack=stack.unshift(a*b)
... | [["-", 8, 734, 0, 121, 64, 749, 0, 652, 735, 22], ["-", 0, 121, 64, 749, 0, 652, 3, 4, 0, 22]] | 4 | 147 | 2 |
input_str = STDIN.gets
input_list = input_str.split(" ")
stack = []
input_list.each do |value|
case value
when '+'
a = stack.pop
b = stack.pop
c = a + b
stack.push c
when '-'
a = stack.pop
b = stack.pop
c = a - b
stack.push c
when '*'
a = stack.pop
b = stack.pop
c = ... | input_str = STDIN.gets
input_list = input_str.split(" ")
stack = []
input_list.each do |value|
case value
when '+'
b = stack.pop
a = stack.pop
c = a + b
stack.push c
when '-'
b = stack.pop
a = stack.pop
c = a - b
stack.push c
when '*'
b = stack.pop
a = stack.pop
c = ... | [["-", 0, 173, 0, 763, 8, 749, 0, 662, 31, 22], ["+", 0, 173, 0, 763, 8, 749, 0, 662, 31, 22]] | 4 | 118 | 12 |
#一つの数式が一行に与えられます
#連続するシンボルは一つの空白で区切られて与えられます
#計算結果を一行に出力してください
require "pp"
input = gets.chomp.split(" ")
stack = %w[]
input.each do |str|
if str =~ /^[0-9]/
stack.push str
else
if str == "+"
second = stack.pop.to_i
first = stack.pop.to_i
stack.push(first-second)
elsif str == "-"
... | #一つの数式が一行に与えられます
#連続するシンボルは一つの空白で区切られて与えられます
#計算結果を一行に出力してください
require "pp"
input = gets.chomp.split(" ")
stack = %w[]
input.each do |str|
if str =~ /^[0-9]/
stack.push str
else
if str == "+"
second = stack.pop.to_i
first = stack.pop.to_i
stack.push(first+second)
elsif str == "-"
... | [["-", 64, 749, 0, 652, 3, 4, 0, 738, 17, 33], ["+", 64, 749, 0, 652, 3, 4, 0, 738, 17, 72]] | 4 | 133 | 2 |
arr = input().split()
stack = list()
for el in arr:
if el.isdigit():
stack.append(int(el))
continue
elif el == "*":
stack.append(stack.pop() * stack.pop())
continue
elif el == "+":
stack.append(stack.pop() + stack.pop())
continue
elif el == "-":
st... | arr = input().split()
stack = list()
for el in arr:
if el.isdigit():
stack.append(int(el))
continue
elif el == "*":
stack.append(stack.pop() * stack.pop())
continue
elif el == "+":
stack.append(stack.pop() + stack.pop())
continue
elif el == "-":
st... | [["+", 0, 652, 3, 4, 0, 657, 31, 664, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72]] | 5 | 116 | 3 |
def is_operator(ele):
if ele == "+" or ele == "-" or ele == "*":
return True
else:
return False
def calc_reverse_polish_notation(A):
stack = []
for i in A:
if is_operator(i):
a = stack.pop()
b = stack.pop()
ans = eval("{0} {1} {2}".format(b, i... | def is_operator(ele):
if ele == "+" or ele == "-" or ele == "*":
return True
else:
return False
def calc_reverse_polish_notation(A):
stack = []
for i in A:
if is_operator(i):
a = stack.pop()
b = stack.pop()
ans = eval("{0} {1} {2}".format(b, i... | [["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 124 | 3 |
class Stack:
data_list = []
def push(self, a):
self.data_list.append(a)
def pop(self):
return self.data_list.pop()
data = eval(input())
lines = data.strip().split()
stack = Stack()
for line in lines:
if line == '+':
num = int(stack.pop()) + int(stack.pop())
stack.push(nu... | class Stack:
data_list = []
def push(self, a):
self.data_list.append(a)
def pop(self):
return self.data_list.pop()
data = input()
lines = data.strip().split()
stack = Stack()
for line in lines:
if line == '+':
num = int(stack.pop()) + int(stack.pop())
stack.push(num)
... | [["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 0, 1, 0, 652, 3, 4, 0, 23, 0, 24], ["-", 3, 4, 0, 23, 0, 652, 3, 4, 0, 25]] | 5 | 183 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.