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
|
|---|---|---|---|---|
ansli=[]
while 1:
a=input().split()
if a[0]=="0" and a[1]=="0" and a[2]=="0":
break
for i in range(len(a)):
a[i]=int(a[i])
x=[]
for i in range(a[0]):
x.append(int(input()))
sum0=0
for i in x:
sum0+=i
sum=sum0*100*((100-a[2])/100)
hit=x[a[1]-1]
if hit==0:
ansli.append(0)
else:
ansli.append(int(sum/hit))
for i in ansli:
print(i)
|
ansli=[]
while 1:
a=input().split()
if a[0]=="0" and a[1]=="0" and a[2]=="0":
break
for i in range(len(a)):
a[i]=int(a[i])
x=[]
for i in range(a[0]):
x.append(int(input()))
sum0=0
for i in x:
sum0+=i
sum=sum0*(100-a[2])
hit=x[a[1]-1]
if hit==0:
ansli.append(0)
else:
ansli.append(int(sum/hit))
for i in ansli:
print(i)
|
[["-", 0, 1, 0, 662, 12, 657, 31, 657, 12, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["-", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["-", 12, 657, 12, 23, 0, 657, 31, 23, 0, 25], ["-", 0, 662, 12, 657, 12, 23, 0, 657, 17, 85], ["-", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612]]
| 5
| 167
|
import static java.lang.Integer.parseInt;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
/**
* Princess's Marriage - Accepted
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null && !line.isEmpty()) {
int N, M;
N = parseInt(line.substring(0, line.indexOf(' ')));
M = parseInt(line.substring(line.indexOf(' ') + 1));
if ((N | M) == 0)
break;
int[] ps = new int[11];
for (int i = 0; i < N; i++) {
line = br.readLine();
int D, P;
D = parseInt(line.substring(0, line.indexOf(' ')));
P = parseInt(line.substring(line.indexOf(' ') + 1));
ps[P] += D;
}
for (int i = ps.length - 1; i >= 0; i--) {
if (ps[i] > 0) {
if (ps[i] <= M) {
M -= ps[i];
ps[i] = 0;
} else {
ps[i] -= M;
}
}
}
int expected = 0;
for (int i = 0; i < ps.length; i++) {
if (ps[i] > 0)
expected += i * ps[i];
}
System.out.println(expected);
} // end while
} // end main
}
|
import static java.lang.Integer.parseInt;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
/**
* Princess's Marriage - Accepted
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null && !line.isEmpty()) {
int N, M;
N = parseInt(line.substring(0, line.indexOf(' ')));
M = parseInt(line.substring(line.indexOf(' ') + 1));
if ((N | M) == 0)
break;
int[] ps = new int[11];
for (int i = 0; i < N; i++) {
line = br.readLine();
int D, P;
D = parseInt(line.substring(0, line.indexOf(' ')));
P = parseInt(line.substring(line.indexOf(' ') + 1));
ps[P] += D;
}
for (int i = ps.length - 1; i >= 0; i--) {
if (ps[i] > 0) {
if (ps[i] <= M) {
M -= ps[i];
ps[i] = 0;
} else {
ps[i] -= M;
M = 0;
}
}
}
int expected = 0;
for (int i = 0; i < ps.length; i++) {
if (ps[i] > 0)
expected += i * ps[i];
}
System.out.println(expected);
} // end while
} // end main
}
|
[["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 499], ["+", 64, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
| 3
| 364
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
int m = sc.nextInt();
if (n == 0 && m == 0)
break;
int[][] map = new int[n][2];
for (int i = 0; i < n; i++) {
map[i][0] = sc.nextInt();
map[i][1] = sc.nextInt();
}
Arrays.sort(map, new Comparator<int[]>() {
public int compare(int[] o1, int[] o2) { return o2[0] - o1[0]; }
});
int sum = 0;
boolean flag = false;
for (int i = 0; i < n; i++) {
if (flag == false) {
if (m <= map[i][0]) {
sum += (map[i][0] - m) * map[i][1];
flag = true;
} else {
m -= map[i][0];
}
} else {
sum += map[i][0] * map[i][1];
}
}
System.out.println(sum);
}
}
}
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
int m = sc.nextInt();
if (n == 0 && m == 0)
break;
int[][] map = new int[n][2];
for (int i = 0; i < n; i++) {
map[i][0] = sc.nextInt();
map[i][1] = sc.nextInt();
}
Arrays.sort(map, new Comparator<int[]>() {
public int compare(int[] o1, int[] o2) { return o2[1] - o1[1]; }
});
int sum = 0;
boolean flag = false;
for (int i = 0; i < n; i++) {
if (flag == false) {
if (m <= map[i][0]) {
sum += (map[i][0] - m) * map[i][1];
flag = true;
} else {
m -= map[i][0];
}
} else {
sum += map[i][0] * map[i][1];
}
}
System.out.println(sum);
}
}
}
|
[["-", 8, 196, 0, 37, 0, 16, 31, 504, 71, 499], ["+", 8, 196, 0, 37, 0, 16, 31, 504, 71, 499], ["-", 8, 196, 0, 37, 0, 16, 12, 504, 71, 499], ["+", 8, 196, 0, 37, 0, 16, 12, 504, 71, 499]]
| 3
| 294
|
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
public class Main {
Scanner sc = new Scanner(System.in);
public void run() {
while (sc.hasNext()) {
int n = sc.nextInt();
int m = sc.nextInt();
if (n == 0 && m == 0)
break;
calc(n, m);
}
}
public void calc(int n, int m) {
int[] list = new int[11];
for (int i = 0; i < n; i++) {
int d = sc.nextInt();
int p = sc.nextInt();
list[p] = list[p] + d;
}
for (int i = 10; i > 0; i--) {
if (m == 0)
break;
else if (list[i] <= m) {
m = m - list[i];
list[i] = 0;
} else {
list[i] = list[i] - m;
}
}
int sum = 0;
for (int i = 0; i < 11; i++) {
sum = sum + list[i] * i;
}
System.out.println(sum);
}
public static void main(String[] args) { new Main().run(); }
}
|
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
public class Main {
Scanner sc = new Scanner(System.in);
public void run() {
while (sc.hasNext()) {
int n = sc.nextInt();
int m = sc.nextInt();
if (n == 0 && m == 0)
break;
calc(n, m);
}
}
public void calc(int n, int m) {
int[] list = new int[11];
for (int i = 0; i < n; i++) {
int d = sc.nextInt();
int p = sc.nextInt();
list[p] = list[p] + d;
}
for (int i = 10; i > 0; i--) {
if (m == 0)
break;
else if (list[i] <= m) {
m = m - list[i];
list[i] = 0;
} else {
list[i] = list[i] - m;
break;
}
}
int sum = 0;
for (int i = 0; i < 11; i++) {
sum = sum + list[i] * i;
}
System.out.println(sum);
}
public static void main(String[] args) { new Main().run(); }
}
|
[["+", 0, 57, 75, 57, 75, 196, 0, 93, 0, 94], ["+", 0, 57, 75, 57, 75, 196, 0, 93, 0, 35]]
| 3
| 289
|
from collections import defaultdict
def getArray(a):
d = defaultdict(int)
n = len(a)
for i in range(n):
s = 0
for j in range(i,n):
s += a[i]
d[s] += 1
return d
while True:
N,M = list(map(int,input().split()))
if N == 0: break
h = [int(input()) for _ in range(N)]
w = [int(input()) for _ in range(M)]
H,W = getArray(h),getArray(w)
print(sum(H[hi]*W[hi] for hi in H))
|
from collections import defaultdict
def getArray(a):
d = defaultdict(int)
n = len(a)
for i in range(n):
s = 0
for j in range(i,n):
s += a[j]
d[s] += 1
return d
while True:
N,M = list(map(int,input().split()))
if N == 0: break
h = [int(input()) for _ in range(N)]
w = [int(input()) for _ in range(M)]
H,W = getArray(h),getArray(w)
print(sum(H[hi]*W[hi] for hi in H))
|
[["-", 8, 196, 0, 1, 0, 677, 12, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 206, 22]]
| 5
| 151
|
while True :
n, m = list(map(int,input().split(" ")))
if (n, m) == (0,0):
break
Lon = [0 for _ in range(1000 * n + 1)]
Lat = [0 for _ in range(1000 * m + 1)]
Lon_sum = []
Lat_sum = []
for _ in range(0,n):
h = int(input())
Lon_sum = [h + j for j in Lon_sum] + [h]
for j in Lon_sum[1:]:
Lon[j] += 1
for _ in range(0,m):
w = int(input())
Lat_sum = [w + j for j in Lat_sum] + [w]
for j in Lat_sum:
Lat[j] += 1
max_width = min(Lon_sum[0],Lat_sum[0])
print(sum([Lon[i]*Lat[i] for i in range(1,max_width+1)]))
|
while True :
n, m = list(map(int,input().split(" ")))
if (n, m) == (0,0):
break
Lon = [0 for _ in range(1000 * n + 1)]
Lat = [0 for _ in range(1000 * m + 1)]
Lon_sum = []
Lat_sum = []
for _ in range(0,n):
h = int(input())
Lon_sum = [h + j for j in Lon_sum] + [h]
for j in Lon_sum:
Lon[j] += 1
for _ in range(0,m):
w = int(input())
Lat_sum = [w + j for j in Lat_sum] + [w]
for j in Lat_sum:
Lat[j] += 1
max_width = min(Lon_sum[0],Lat_sum[0])
print(sum([Lon[i]*Lat[i] for i in range(1,max_width+1)]))
|
[["-", 0, 7, 8, 196, 0, 7, 12, 206, 0, 70], ["-", 8, 196, 0, 7, 12, 206, 206, 663, 0, 612], ["-", 8, 196, 0, 7, 12, 206, 206, 663, 0, 102], ["-", 0, 7, 8, 196, 0, 7, 12, 206, 0, 73]]
| 5
| 213
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
rr = []
while True:
n,m = LI()
if n == 0 and m == 0:
break
a = [I() for _ in range(n)]
b = [I() for _ in range(m)]
ar = [0] * (n+1)
for i in range(n):
ar[i+1] = a[i] + a[i]
ad = collections.defaultdict(int)
for i in range(n+1):
for j in range(i+1,n+1):
ad[ar[j]-ar[i]] += 1
br = [0] * (m+1)
for i in range(m):
br[i+1] = b[i] + b[i]
bd = collections.defaultdict(int)
for i in range(m+1):
for j in range(i+1,m+1):
bd[br[j]-br[i]] += 1
r = 0
for k in ad.keys():
r += ad[k] * bd[k]
rr.append(r)
return '\n'.join(map(str, rr))
print(main())
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
rr = []
while True:
n,m = LI()
if n == 0 and m == 0:
break
a = [I() for _ in range(n)]
b = [I() for _ in range(m)]
ar = [0] * (n+1)
for i in range(n):
ar[i+1] = ar[i] + a[i]
ad = collections.defaultdict(int)
for i in range(n+1):
for j in range(i+1,n+1):
ad[ar[j]-ar[i]] += 1
br = [0] * (m+1)
for i in range(m):
br[i+1] = br[i] + b[i]
bd = collections.defaultdict(int)
for i in range(m+1):
for j in range(i+1,m+1):
bd[br[j]-br[i]] += 1
r = 0
for k in ad.keys():
r += ad[k] * bd[k]
rr.append(r)
return '\n'.join(map(str, rr))
print(main())
|
[["-", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22]]
| 5
| 472
|
def solve(lis_height,lis_width):
h=len(lis_height)
w=len(lis_width)
dic = {}
for i in range(h):
k=0
for j in range(i,h):
k+=lis_height[j]
if k in dic:
dic[k]+=1
else:
dic[k]=1
ans = 0
for i in range(w):
k=0
for j in range(j,w):
k+=lis_width[j]
if k in dic:
ans += dic[k]
print(ans)
while True:
h,w=[int(i) for i in input().split(' ')]
# print(a)
if h == 0:
break
lis_h =[]
lis_w=[]
for i in range(h):
lis_h.append(int(input()))
for i in range(w):
lis_w.append(int(input()))
solve(lis_h,lis_w)
|
def solve(lis_height,lis_width):
h=len(lis_height)
w=len(lis_width)
dic = {}
for i in range(h):
k=0
for j in range(i,h):
k+=lis_height[j]
if k in dic:
dic[k]+=1
else:
dic[k]=1
ans = 0
#print(dic)
#print(w,'a')
for i in range(w):
k=0
for j in range(i,w):
k+=lis_width[j]
# print(j)
if k in dic:
ans += dic[k]
#print(k,dic[k])
print(ans)
while True:
h,w=[int(i) for i in input().split(' ')]
# print(a)
if h == 0:
break
lis_h =[]
lis_w=[]
for i in range(h):
lis_h.append(int(input()))
for i in range(w):
lis_w.append(int(input()))
solve(lis_h,lis_w)
|
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
| 5
| 200
|
import java.util.Scanner;
public class Main {
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int N, M, P;
while ((N = scan.nextInt()) != 0 && (M = scan.nextInt()) != 0 &&
(P = scan.nextInt()) != 0) {
int member = 0;
int[] voteNum = new int[N + 1];
for (int i = 1; i <= N; i++) {
voteNum[i] = scan.nextInt();
member += voteNum[i];
}
if (voteNum[M] == 0) {
System.out.println(0);
continue;
}
int pool = member * (100 - P);
System.out.println(pool / (voteNum[M]));
}
}
}
|
import java.util.Scanner;
public class Main {
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int N, M, P;
while ((N = scan.nextInt()) != 0 | (M = scan.nextInt()) != 0 |
(P = scan.nextInt()) != 0) {
int member = 0;
int[] voteNum = new int[N + 1];
for (int i = 1; i <= N; i++) {
voteNum[i] = scan.nextInt();
member += voteNum[i];
}
if (voteNum[M] == 0) {
System.out.println(0);
continue;
}
int pool = member * (100 - P);
System.out.println(pool / (voteNum[M]));
}
}
}
|
[["-", 0, 52, 15, 15, 0, 16, 31, 16, 17, 98], ["+", 0, 52, 15, 15, 0, 16, 31, 16, 17, 139], ["-", 8, 196, 0, 52, 15, 15, 0, 16, 17, 98], ["+", 8, 196, 0, 52, 15, 15, 0, 16, 17, 139]]
| 3
| 184
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (true) {
int n = in.nextInt();
int m = in.nextInt();
int p = in.nextInt();
int xm = 0;
if (n == 0)
break;
int sum = 0;
for (int i = 0; i < n; i++) {
int x = in.nextInt();
sum += x;
if (i + 1 == m)
xm = x;
}
int res = m == 0 ? 0 : (sum * (100 - p)) / xm;
System.out.println((int)res);
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (true) {
int n = in.nextInt();
int m = in.nextInt();
int p = in.nextInt();
int xm = 0;
if (n == 0)
break;
int sum = 0;
for (int i = 0; i < n; i++) {
int x = in.nextInt();
sum += x;
if (i + 1 == m)
xm = x;
}
int res = xm == 0 ? 0 : (sum * (100 - p)) / xm;
System.out.println((int)res);
}
}
}
|
[["-", 0, 503, 49, 200, 51, 510, 15, 16, 31, 22], ["+", 0, 503, 49, 200, 51, 510, 15, 16, 31, 22]]
| 3
| 160
|
/*
AizuOnline A2018
Princess's Gamble
*/
#include <float.h>
#include <stdio.h>
int M, N, P;
int hyousuu[100];
long int sousuu;
long int haitou;
main() {
int i;
while (EOF != scanf("%d %d %d", &N, &M, &P) && (N || M || P)) {
sousuu = 0;
for (i = 0; i < N; i++) {
scanf("%d", &hyousuu[i]);
sousuu += hyousuu[i];
}
if (hyousuu[M - 1])
haitou = (double)sousuu / (double)hyousuu[M - 1] * (double)P;
else
haitou = 0;
printf("%ld\n", haitou);
}
return (0);
}
|
/*
AizuOnline A2018
Princess's Gamble
*/
#include <float.h>
#include <stdio.h>
int M, N, P;
int hyousuu[100];
long int sousuu;
long int haitou;
main() {
int i;
while (EOF != scanf("%d %d %d", &N, &M, &P) && (N || M || P)) {
sousuu = 0;
for (i = 0; i < N; i++) {
scanf("%d", &hyousuu[i]);
sousuu += hyousuu[i];
}
if (hyousuu[M - 1])
haitou = (double)sousuu / (double)hyousuu[M - 1] * (double)(100 - P);
else
haitou = 0;
printf("%ld\n", haitou);
}
return (0);
}
|
[["+", 0, 11, 12, 16, 12, 74, 51, 23, 0, 24], ["+", 12, 16, 12, 74, 51, 23, 0, 16, 31, 13], ["+", 12, 16, 12, 74, 51, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 12, 74, 51, 23, 0, 25]]
| 0
| 155
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
int N, M, P;
int sum, ans;
int X[1001];
while (scanf("%d %d %d", &N, &M, &P) != EOF && (!N && !M && !P)) {
sum = 0;
for (int i = 0; i < N; i++) {
cin >> X[i];
sum += X[i];
}
P = 100 - P;
if (X[M - 1] == 0)
ans = 0;
else
ans = sum * P / X[M - 1];
cout << ans << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
int N, M, P;
int sum, ans;
int X[1001];
while (scanf("%d %d %d", &N, &M, &P) != EOF) {
if (!N && !M && !P)
break;
sum = 0;
for (int i = 0; i < N; i++) {
cin >> X[i];
sum += X[i];
}
P = 100 - P;
if (X[M - 1] == 0)
ans = 0;
else
ans = sum * P / X[M - 1];
cout << ans << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["-", 0, 52, 15, 339, 51, 16, 12, 23, 0, 25], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 52, 8, 9, 0, 57, 64, 93, 0, 94], ["+", 0, 52, 8, 9, 0, 57, 64, 93, 0, 35]]
| 1
| 144
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
int N, M, P;
int sum, ans;
int X[1001];
while (scanf("%d %d %d", &N, &M, &P) != EOF) {
if (N != 0 && M != 0 && P != 0)
break;
sum = 0;
for (int i = 0; i < N; i++) {
cin >> X[i];
sum += X[i];
}
P = 100 - P;
if (X[M - 1] == 0)
ans = 0;
else
ans = sum * P / X[M - 1];
cout << ans << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
int N, M, P;
int sum, ans;
int X[1001];
while (scanf("%d %d %d", &N, &M, &P) != EOF) {
if (N == 0 && M == 0 && P == 0)
break;
sum = 0;
for (int i = 0; i < N; i++) {
cin >> X[i];
sum += X[i];
}
P = 100 - P;
if (X[M - 1] == 0)
ans = 0;
else
ans = sum * P / X[M - 1];
cout << ans << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 79], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 60], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 79], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60]]
| 1
| 149
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define fori(i, k, n) for (int i = k; i < n; i++)
using namespace std;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const int dX[8] = {0, 1, 1, 1, 0, -1, -1, -1},
dY[8] = {1, 1, 0, -1, -1, -1, 0, 1};
/*
(char)'1' - (int)48 = (int)1;
*/
int main() {
int n, m, p;
cin >> n >> m >> p;
while (n != 0 && m != 0 && p != 0) {
int a[110];
double al = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
al += a[i] * 100;
}
al = al * (100 - p) / 100;
if (a[m - 1] == 0) {
cout << 0 << endl;
} else {
al /= a[m - 1];
int ans = al;
cout << ans << endl;
}
cin >> n >> m >> p;
}
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define fori(i, k, n) for (int i = k; i < n; i++)
using namespace std;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const int dX[8] = {0, 1, 1, 1, 0, -1, -1, -1},
dY[8] = {1, 1, 0, -1, -1, -1, 0, 1};
/*
(char)'1' - (int)48 = (int)1;
*/
int main() {
int n, m, p;
cin >> n >> m >> p;
while (n != 0 || m != 0 || p != 0) {
int a[110];
double al = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
al += a[i] * 100;
}
al = al * (100 - p) / 100;
if (a[m - 1] == 0) {
cout << 0 << endl;
} else {
al /= a[m - 1];
int ans = al;
cout << ans << endl;
}
cin >> n >> m >> p;
}
}
|
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 106], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 106]]
| 1
| 265
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, p, x, d, a;
while (cin >> n >> m >> p, n, m, p) {
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> x;
if (i + 1 == m)
d = x;
sum += x;
}
a = sum * 100 * (100 - p) / 100;
if (d != 0)
cout << a / d << endl;
else
cout << 0 << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, p, x, d, a;
while (cin >> n >> m >> p, n) {
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> x;
if (i + 1 == m)
d = x;
sum += x;
}
a = sum * 100 * (100 - p) / 100;
if (d != 0)
cout << a / d << endl;
else
cout << 0 << endl;
}
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 34, 0, 21], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 31, 22], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 0, 21], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 12, 22]]
| 1
| 119
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
for (int N, M, P; cin >> N >> M >> P, N, M, P;) {
int bet = 0;
vector<int> l;
for (int i = 0; i < N; i++) {
int X;
cin >> X;
l.push_back(X);
bet += X;
}
if (l[M - 1]) {
cout << (bet * (100 - P) / l[M - 1]) << endl;
} else {
cout << 0 << endl;
}
}
return 0;
}
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
for (int N, M, P; cin >> N >> M >> P, N;) {
int bet = 0;
vector<int> l;
for (int i = 0; i < N; i++) {
int X;
cin >> X;
l.push_back(X);
bet += X;
}
if (l[M - 1]) {
cout << (bet * (100 - P) / l[M - 1]) << endl;
} else {
cout << 0 << endl;
}
}
return 0;
}
|
[["-", 8, 9, 0, 7, 15, 34, 12, 34, 0, 21], ["-", 0, 7, 15, 34, 12, 34, 12, 34, 31, 22], ["-", 0, 7, 15, 34, 12, 34, 12, 34, 0, 21], ["-", 0, 7, 15, 34, 12, 34, 12, 34, 12, 22]]
| 1
| 129
|
#include <iostream>
using namespace std;
int main() {
int n, m, p;
while (cin >> n >> m >> p, n, m, p) {
int ans = 0, d[n];
double sum = 0.0;
for (int i = 0; i < n; i++) {
cin >> d[i];
sum += d[i];
}
sum *= 100;
sum -= sum * (p * 1.0 / 100);
if (d[m - 1]) {
ans = sum / d[m - 1];
cout << ans << endl;
} else
cout << 0 << endl;
}
}
|
#include <iostream>
using namespace std;
int main() {
int n, m, p;
while (cin >> n >> m >> p, n) {
int ans = 0, d[n];
double sum = 0.0;
for (int i = 0; i < n; i++) {
cin >> d[i];
sum += d[i];
}
sum *= 100;
sum -= sum * (p * 1.0 / 100);
if (d[m - 1]) {
ans = sum / d[m - 1];
cout << ans << endl;
} else
cout << 0 << endl;
}
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 34, 0, 21], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 31, 22], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 0, 21], ["-", 15, 339, 51, 34, 12, 34, 12, 34, 12, 22]]
| 1
| 133
|
#include <iostream>
using namespace std;
int main() {
int N, M, P;
int x[100];
while (cin >> N >> M >> P, N) {
int winner = 0;
int sum = 0;
for (int i = 0; i < N; i++) {
cin >> x[i];
if (i + 1 == M)
winner = x[i];
sum += x[i] * P;
}
cout << (winner ? sum / winner : 0) << endl;
}
}
|
#include <iostream>
using namespace std;
int main() {
int N, M, P;
int x[100];
while (cin >> N >> M >> P, N) {
int winner = 0;
int sum = 0;
for (int i = 0; i < N; i++) {
cin >> x[i];
if (i + 1 == M)
winner = x[i];
sum += x[i] * (100 - P);
}
cout << (winner ? sum / winner : 0) << endl;
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 13], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
| 1
| 110
|
#include <stdio.h>
int main() {
int N, M, P;
while (1) {
scanf("%d %d %d", &N, &M, &P);
if (N == 0 && M == 0 && P == 0)
break;
int x, s = 0, y = 0;
for (int i = 0; i < N; i++) {
scanf("%d", &x);
s += x;
if (M == i + 1)
y = x;
}
if (y != 0) {
int t = 100 * s;
t = t / y * (100 - P) / 100;
printf("%d\n", t);
} else
printf("0\n");
}
return 0;
}
|
#include <stdio.h>
int main() {
int N, M, P;
while (1) {
scanf("%d %d %d", &N, &M, &P);
if (N == 0 && M == 0 && P == 0)
break;
int x, s = 0, y = 0;
for (int i = 0; i < N; i++) {
scanf("%d", &x);
s += x;
if (M == i + 1)
y = x;
}
if (y != 0) {
double t = 100 * s;
t = t / y * (100 - P) / 100;
printf("%d\n", (int)t);
} else
printf("0\n");
}
return 0;
}
|
[["-", 8, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["+", 0, 1, 0, 2, 3, 4, 0, 74, 0, 24], ["+", 0, 2, 3, 4, 0, 74, 39, 77, 39, 40], ["+", 0, 1, 0, 2, 3, 4, 0, 74, 0, 25]]
| 1
| 157
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
while (true) {
int N, M, P;
cin >> N >> M >> P;
if (N == 0) {
break;
}
int atari_count;
int ticket_count = 0;
for (int i = 0; i < N; i++) {
int input;
cin >> input;
ticket_count += input;
if (i + 1 == M) {
atari_count = input;
}
}
if (atari_count != 0) {
printf("%d", 100 * ticket_count * (100 - P) / 100 / atari_count);
} else {
printf("0");
}
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
while (true) {
int N, M, P;
cin >> N >> M >> P;
if (N == 0) {
break;
}
int atari_count;
int ticket_count = 0;
for (int i = 0; i < N; i++) {
int input;
cin >> input;
ticket_count += input;
if (i + 1 == M) {
atari_count = input;
}
}
if (atari_count != 0) {
printf("%d", 100 * ticket_count * (100 - P) / 100 / atari_count);
} else {
printf("0");
}
puts("");
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 136
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define pb(n) push_back(n)
#define mp(n, m) make_pair(n, m)
#define fi first
#define se second
#define all(r) (r).begin(), (r).end()
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define rep(i, n) REP(i, 0, n)
#define REPE(i, s, e) for (int i = s; i > e; i--)
#define repe(i, n) REPE(i, n, -1)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vi> vii;
const int IMAX = ((1 << 30) - 1) * 2 + 1;
const int INF = 100000000;
const double EPS = 1e-10;
// int mod=1000000007
int main() {
int n, m, p;
while (cin >> n >> m >> p) {
if (n == 0 && m == 0 && p == 0)
break;
int sum = 0, w, t;
for (int i = 0; i < n; i++) {
cin >> t;
sum += t;
if (i == m - 1)
w = t;
}
double d = (double)sum * (100 - p) / 100;
if (w == 0)
cout << "0" << endl;
else
cout << (int)(d / w) << endl;
}
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define pb(n) push_back(n)
#define mp(n, m) make_pair(n, m)
#define fi first
#define se second
#define all(r) (r).begin(), (r).end()
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define rep(i, n) REP(i, 0, n)
#define REPE(i, s, e) for (int i = s; i > e; i--)
#define repe(i, n) REPE(i, n, -1)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vi> vii;
const int IMAX = ((1 << 30) - 1) * 2 + 1;
const int INF = 100000000;
const double EPS = 1e-10;
// int mod=1000000007
int main() {
int n, m, p;
while (cin >> n >> m >> p) {
if (n == 0 && m == 0 && p == 0)
break;
int sum = 0, w, t;
for (int i = 0; i < n; i++) {
cin >> t;
sum += t;
if (i == m - 1)
w = t;
}
sum *= 100;
double d = (double)sum * (100 - p) / 100;
if (w == 0)
cout << "0" << endl;
else
cout << (int)(d / w) << endl;
// cout << sum << endl;
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 297
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, a[100], x, p, s;
while (1) {
cin >> n >> x >> p;
if ((n == 0) && (x == 0) && (p == 0)) {
return 0;
}
s = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
s += a[i];
}
if (a[x - 1] == 0) {
s = 0;
} else {
s = s * (100 - p) / a[x - 1];
cout << s << "\n";
}
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, a[100], x, p, s;
while (1) {
cin >> n >> x >> p;
if ((n == 0) && (x == 0) && (p == 0)) {
return 0;
}
s = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
s += a[i];
}
if (a[x - 1] == 0) {
s = 0;
} else {
s = s * (100 - p) / a[x - 1];
}
cout << s << "\n";
}
return 0;
}
|
[["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46], ["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
| 1
| 157
|
#include <algorithm>
#include <iostream>
#include <queue>
#include <stdlib.h>
#include <string>
using namespace std;
int main() {
int n, m, p;
while (cin >> n >> m >> p && n != 0) {
int a[104] = {0};
int sum = 0;
for (int i = 1; i < n + 1; i++) {
cin >> a[i];
sum = sum + a[i];
}
int ans = sum * p;
if (a[m] == 0)
ans = 0;
else
ans = ans / a[m];
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <queue>
#include <stdlib.h>
#include <string>
using namespace std;
int main() {
int n, m, p;
while (cin >> n >> m >> p && n != 0) {
int a[104] = {0};
int sum = 0;
for (int i = 1; i < n + 1; i++) {
cin >> a[i];
sum = sum + a[i];
}
int ans = sum * (100 - p);
if (a[m] == 0)
ans = 0;
else
ans = ans / a[m];
cout << ans << endl;
}
return 0;
}
|
[["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 24], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 31, 13], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 43, 49, 50, 51, 16, 12, 23, 0, 25]]
| 1
| 131
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, h;
int data[110];
while (1) {
cin >> n >> m >> h;
if (n == 0 && m == 0 && h == 0)
break;
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> data[i];
sum += data[i];
}
if (data[m - 1] == 0) {
cout << "0" << endl;
continue;
}
sum = sum * 100;
sum = sum * h;
sum = sum / 100;
cout << sum / data[m - 1] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, h;
int data[110];
while (1) {
cin >> n >> m >> h;
if (n == 0 && m == 0 && h == 0)
break;
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> data[i];
sum += data[i];
}
if (data[m - 1] == 0) {
cout << "0" << endl;
continue;
}
sum = sum * 100;
sum = sum * (100 - h);
sum = sum / 100;
cout << sum / data[m - 1] << endl;
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 13], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
| 1
| 144
|
#include <cstdio>
int N, M, P, S, X[101];
int main() {
while (true) {
scanf("%d%d%d", &N, &M, &P);
if (N == 0) {
break;
}
for (int i = 1; i <= N; i++) {
scanf("%d", &X[i]);
S += X[i];
}
printf("%d\n", X[M] == 0 ? 0 : (100 - P) * S / X[M]);
}
return 0;
}
|
#include <cstdio>
int N, M, P, S, X[101];
int main() {
while (true) {
S = 0;
scanf("%d%d%d", &N, &M, &P);
if (N == 0) {
break;
}
for (int i = 1; i <= N; i++) {
scanf("%d", &X[i]);
S += X[i];
}
printf("%d\n", X[M] == 0 ? 0 : (100 - P) * S / X[M]);
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 123
|
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <stack>
#define rep(i, x) for (int i = 0; i < x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rep_to(a, i, x) for (int i = a; i < x; i++)
using namespace std;
int main() {
int N, M, P;
while (cin >> N >> M >> P && N) {
int x[100000] = {};
int sum = 0;
rep(i, N) {
cin >> x[i];
sum += x[i] * 100;
}
if (x[M - 1] != 0)
cout << sum / x[M - 1] * (100 - P) / 100 << endl;
else
cout << 0 << endl;
}
}
|
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <stack>
#define rep(i, x) for (int i = 0; i < x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rep_to(a, i, x) for (int i = a; i < x; i++)
using namespace std;
int main() {
int N, M, P;
while (cin >> N >> M >> P && N) {
int x[100000] = {};
double sum = 0;
rep(i, N) {
cin >> x[i];
sum += x[i] * 100;
}
if (x[M - 1] != 0)
cout << floor(sum / x[M - 1] * (100 - P) / 100) << endl;
else
cout << 0 << endl;
}
}
|
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 64, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
| 1
| 148
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, l, n) for (lint i = l; i < n; i++)
#define rer(i, l, n) for (lint i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
int n, m, p;
while (1) {
cin >> n >> m >> p;
if (n + m + p == 0)
break;
int sum = 0, win;
rep(i, 1, n + 1) {
int a;
cin >> a;
sum += a;
if (i == m)
win = a;
}
o((win == 0 ? 0 : p * sum / win));
}
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, l, n) for (lint i = l; i < n; i++)
#define rer(i, l, n) for (lint i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
int n, m, p;
while (1) {
cin >> n >> m >> p;
if (n + m + p == 0)
break;
int sum = 0, win;
rep(i, 1, n + 1) {
int a;
cin >> a;
sum += a;
if (i == m)
win = a;
}
o((win == 0 ? 0 : (100 - p) * sum / win));
}
}
|
[["+", 0, 41, 75, 16, 31, 16, 31, 23, 0, 24], ["+", 75, 16, 31, 16, 31, 23, 0, 16, 31, 13], ["+", 75, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 41, 75, 16, 31, 16, 31, 23, 0, 25]]
| 1
| 206
|
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 1; i <= n; i++)
int main() {
while (true) {
int n, m, p;
cin >> n >> m >> p;
if (n == 0 && m == 0 && p == 0)
break;
int x;
int hito = 0, sum = 0;
;
rep(i, n) {
cin >> x;
sum += x;
if (i == m) {
hito = x;
}
if (hito == 0) {
cout << 0 << '\n';
} else {
cout << sum * (100 - p) / hito << '\n';
}
}
}
}
|
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 1; i <= n; i++)
int main() {
while (true) {
int n, m, p;
cin >> n >> m >> p;
if (n == 0 && m == 0 && p == 0)
break;
int x;
int hito = 0, sum = 0;
;
rep(i, n) {
cin >> x;
sum += x;
if (i == m) {
hito = x;
}
}
if (hito == 0) {
cout << 0 << '\n';
} else {
cout << sum * (100 - p) / hito << '\n';
}
}
}
|
[["+", 0, 52, 8, 9, 0, 14, 8, 9, 0, 46], ["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
| 1
| 133
|
#include <iostream>
using namespace std;
int main() {
int n, m, p;
int num[101];
while (cin >> n >> m >> p, n | m | p) {
int total = 0;
for (int i = 1; i <= n; i++) {
cin >> num[i];
total += num[i] * (100 - p);
}
if (!num[n]) {
cout << 0 << endl;
continue;
}
cout << (total / num[m]) << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n, m, p;
int num[101];
while (cin >> n >> m >> p, n | m | p) {
int total = 0;
for (int i = 1; i <= n; i++) {
cin >> num[i];
total += num[i] * (100 - p);
}
if (!num[m]) {
cout << 0 << endl;
continue;
}
cout << (total / num[m]) << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 91, 28, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 91, 28, 69, 341, 342, 0, 22]]
| 1
| 118
|
#include <iostream>
using namespace std;
#define REP(i, n) for (int(i) = 0; i < (n); i++)
int nextInt() {
int d;
cin >> d;
return d;
}
int main() {
while (true) {
int N = nextInt();
int M = nextInt() - 1;
int P = nextInt();
if (N + M + P == -1)
break;
int sum = 0;
int xm = 0;
REP(i, N) {
int x = nextInt();
sum += x;
if (i == M)
xm = x;
}
if (xm == 0) {
cout << 0 << endl;
} else {
cout << sum * (100 - P) / xm;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
#define REP(i, n) for (int(i) = 0; i < (n); i++)
int nextInt() {
int d;
cin >> d;
return d;
}
int main() {
while (true) {
int N = nextInt();
int M = nextInt() - 1;
int P = nextInt();
if (N + M + P == -1)
break;
int sum = 0;
int xm = 0;
REP(i, N) {
int x = nextInt();
sum += x;
if (i == M)
xm = x;
}
if (xm == 0) {
cout << 0 << endl;
} else {
cout << sum * (100 - P) / xm << endl;
}
}
return 0;
}
|
[["+", 75, 76, 0, 9, 0, 1, 0, 16, 17, 151], ["+", 75, 76, 0, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 148
|
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define el endl
#define fd fixed
#define INF INT_MAX / 2 - 1
using namespace std;
int main() {
int n, m, p, x, sum, num;
while (cin >> n >> m >> p, n | m | p) {
sum = 0;
for (int i = 0; i < n; i++) {
cin >> x;
sum += x;
if (i == m - 1)
num = x;
}
if (num == 0)
cout << x << el;
else
cout << sum * (100 - p) / num << el;
}
}
|
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define el endl
#define fd fixed
#define INF INT_MAX / 2 - 1
using namespace std;
int main() {
int n, m, p, x, sum, num;
while (cin >> n >> m >> p, n | m | p) {
sum = 0;
for (int i = 0; i < n; i++) {
cin >> x;
sum += x;
if (i == m - 1)
num = x;
}
if (num == 0)
cout << num << el;
else
cout << sum * (100 - p) / num << el;
}
}
|
[["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 129
|
#include <iostream>
using namespace std;
int main() {
int n, m, p;
while (cin >> n >> m >> p) {
if (n == 0 && m == 0 && p == 0)
break;
int x[n];
for (int i = 0; i < n; i++) {
cin >> x[i];
}
if (x[m - 1] == 0) {
cout << 0 << endl;
break;
}
int t = 0;
for (int i = 0; i < n; i++) {
t = t + x[i];
}
cout << (t * (100 - p)) / x[m - 1] << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n, m, p;
while (cin >> n >> m >> p) {
if (n == 0 && m == 0 && p == 0)
break;
int x[n];
for (int i = 0; i < n; i++) {
cin >> x[i];
}
if (x[m - 1] == 0) {
cout << 0 << endl;
} else {
int t = 0;
for (int i = 0; i < n; i++) {
t = t + x[i];
}
cout << (t * (100 - p)) / x[m - 1] << endl;
}
}
return 0;
}
|
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35], ["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
| 1
| 151
|
#include <stdio.h>
int main() {
int m, n, p, i, sum = 0, ans = 0;
int x[100] = {};
for (;;) {
scanf("%d %d %d", &n, &m, &p);
if (n == 0 && m == 0 && p == 0) {
break;
}
for (i = 1; i <= n; i++) {
scanf("%d", &x[i]);
sum += x[i];
}
if (x[m] != 0) {
ans = (100 * sum / x[m]) * ((100 - p) * 0.01);
}
if (x[m] == 0) {
printf("0\n");
} else {
printf("%d\n", ans);
}
ans = 0;
sum = 0;
for (i = 1; i <= n; i++) {
x[i] = 0;
}
}
return 0;
}
|
#include <stdio.h>
int main() {
int m, n, p, i, sum = 0, ans = 0;
int x[100] = {};
for (;;) {
scanf("%d %d %d", &n, &m, &p);
if (n == 0 && m == 0 && p == 0) {
break;
}
for (i = 1; i <= n; i++) {
scanf("%d", &x[i]);
sum += x[i];
}
if (x[m] != 0) {
ans = ((double)100 * sum / x[m]) * ((100 - p) * 0.01);
}
if (x[m] == 0) {
printf("0\n");
} else {
printf("%d\n", ans);
}
ans = 0;
sum = 0;
for (i = 1; i <= n; i++) {
x[i] = 0;
}
}
return 0;
}
|
[["+", 31, 23, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 16, 31, 16, 31, 74, 39, 77, 39, 40], ["+", 31, 23, 0, 16, 31, 16, 31, 74, 0, 25]]
| 1
| 209
|
#include <iostream>
using namespace std;
int main() {
int n, m, p, x;
int s, winner;
int result;
cin >> n >> m >> p;
while (n || m || p) {
s = 0;
for (int i = 0; i < n; ++i) {
cin >> x;
if (i + 1 == m)
winner = x;
s += x;
}
if (winner) {
result = (s * p) / winner;
} else {
result = 0;
}
cout << result << endl;
cin >> n >> m >> p;
}
}
|
#include <iostream>
using namespace std;
int main() {
int n, m, p, x;
int s, winner;
int result;
cin >> n >> m >> p;
while (n || m || p) {
s = 0;
for (int i = 0; i < n; ++i) {
cin >> x;
if (i + 1 == m)
winner = x;
s += x;
}
if (winner) {
result = (s * (100 - p)) / winner;
} else {
result = 0;
}
cout << result << endl;
cin >> n >> m >> p;
}
}
|
[["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 31, 13], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
| 1
| 124
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, p;
int player[101];
while (true) {
int ans;
cin >> n >> m >> p;
if (n == 0)
break;
int voter = 0;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
player[i] = x;
voter += x;
}
if (player[m] == 0)
ans = 0;
else
ans = voter * p / player[m];
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, p;
int player[101];
while (true) {
int ans;
cin >> n >> m >> p;
if (n == 0)
break;
int voter = 0;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
player[i] = x;
voter += x;
}
if (player[m] == 0)
ans = 0;
else
ans = voter * (100 - p) / player[m];
cout << ans << endl;
}
}
|
[["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 31, 13], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 25]]
| 1
| 204
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12
int main(void) {
while (true) {
double n, p;
int m;
cin >> n >> m >> p;
if (!n && !m && !p)
break;
double x[100], sum = 0;
REP(i, n) {
cin >> x[i];
sum += x[i];
}
// cout << sum << endl;
// cout << (sum * 100 * (1 - p / 100)) << " " << x[m - 1] << endl;
if (x[m - 1] == 0)
cout << 0 << endl;
else {
double temp = (sum * 100 * (1 - p / 100));
int ans = temp / x[m - 1];
cout << ans << endl;
}
// cout << (int)((sum * 100 * (1 - p / 100)) / x[m - 1]) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12
int main(void) {
while (true) {
double n, p;
int m;
cin >> n >> m >> p;
if (!n && !m && !p)
break;
double x[100], sum = 0;
REP(i, n) {
cin >> x[i];
sum += x[i];
}
// cout << sum << endl;
// cout << (sum * 100 * (1 - p / 100)) << " " << x[m - 1] << endl;
if (x[m - 1] == 0)
cout << 0 << endl;
else {
double temp = (sum * (100 - p));
int ans = temp / x[m - 1];
cout << ans << endl;
}
// cout << (int)((sum * 100 * (1 - p / 100)) / x[m - 1]) << endl;
}
return 0;
}
|
[["-", 49, 50, 51, 23, 0, 16, 31, 16, 12, 13], ["-", 0, 43, 49, 50, 51, 23, 0, 16, 17, 48], ["-", 51, 23, 0, 16, 12, 23, 0, 16, 31, 13], ["+", 51, 23, 0, 16, 12, 23, 0, 16, 31, 13], ["-", 0, 16, 12, 23, 0, 16, 12, 16, 17, 85], ["-", 0, 16, 12, 23, 0, 16, 12, 16, 12, 13]]
| 1
| 219
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for (int i = 0; i < N; i++)
#define Reps(i, x, N) for (int i = x; i < N; i++)
const int LLINF = 1LL << 60;
signed main() {
int N, M, P;
while (cin >> N >> M >> P, N || M || P) {
int A[105];
P = 100 - P;
Rep(i, N) cin >> A[i];
--M;
if (A[M])
cout << accumulate(A, A + N, 0LL) * 100 / A[M] * P / 100 << endl;
else
cout << 0 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for (int i = 0; i < N; i++)
#define Reps(i, x, N) for (int i = x; i < N; i++)
const int LLINF = 1LL << 60;
signed main() {
int N, M, P;
while (cin >> N >> M >> P, N || M || P) {
int A[105];
P = 100 - P;
Rep(i, N) cin >> A[i];
--M;
if (A[M])
cout << accumulate(A, A + N, 0LL) * 100 * P / A[M] / 100 << endl;
else
cout << 0 << endl;
}
return 0;
}
|
[["+", 31, 16, 12, 16, 31, 16, 31, 16, 17, 48], ["+", 31, 16, 12, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["-", 0, 16, 31, 16, 12, 16, 31, 16, 12, 22]]
| 1
| 138
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
main() {
int N, M, P;
while (cin >> N >> M >> P, N && M && P) {
int X[100];
int sum = 0;
for (int i = 0; i < N; i++)
cin >> X[i], sum += X[i] * 100;
sum *= (100 - P);
if (X[M - 1] == 0)
cout << 0 << endl;
else
cout << sum / X[M - 1] / 100 << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, P;
while (cin >> N >> M >> P, N + M + P) {
int X[100];
int sum = 0;
for (int i = 0; i < N; i++)
cin >> X[i], sum += X[i] * 100;
sum *= (100 - P);
if (X[M - 1] == 0)
cout << 0 << endl;
else
cout << sum / X[M - 1] / 100 << endl;
}
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 15, 339, 51, 34, 12, 16, 31, 16, 17, 98], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 17, 72], ["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 72]]
| 1
| 121
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = (0); (i) < (int)(n); ++(i))
using ll = long long;
int main() {
int n, m, p;
while (cin >> n >> m >> p and n and m and p) {
int sum = 0, hit = 0;
rep(i, n) {
int t;
cin >> t;
sum += 100 * t;
if (i == m - 1)
hit += t;
}
if (hit == 0)
cout << 0 << endl;
else
cout << (int)(sum * (100.0 - p) / 100.0 / hit) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = (0); (i) < (int)(n); ++(i))
using ll = long long;
int main() {
int n, m, p;
while (cin >> n >> m >> p and (n or m or p)) {
int sum = 0, hit = 0;
rep(i, n) {
int t;
cin >> t;
sum += 100 * t;
if (i == m - 1)
hit += t;
}
if (hit == 0)
cout << 0 << endl;
else
cout << (int)(sum * (100.0 - p) / 100 / hit) << endl;
}
return 0;
}
|
[["+", 0, 52, 15, 339, 51, 16, 12, 23, 0, 24], ["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 355], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 17, 354], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 355], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 354], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["-", 12, 74, 51, 23, 0, 16, 31, 16, 12, 13], ["+", 12, 74, 51, 23, 0, 16, 31, 16, 12, 13]]
| 1
| 130
|
#include <iostream>
using namespace std;
int main() {
int N, M, P;
while (cin >> N >> M >> P, N != 0) {
int num = 0;
int sum = 0;
for (int i = 0; i < N; i++) {
int X;
cin >> X;
if (i == M - 1) {
num = X;
}
sum += X;
}
cout << (num != 0 ? sum * 100 / num * (100 - P) / 100 : 0) << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int N, M, P;
while (cin >> N >> M >> P, N != 0) {
int num = 0;
int sum = 0;
for (int i = 0; i < N; i++) {
int X;
cin >> X;
if (i == M - 1) {
num = X;
}
sum += X;
}
cout << (num != 0 ? sum * (100 - P) / num : 0) << endl;
}
return 0;
}
|
[["-", 64, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["-", 0, 41, 64, 16, 31, 16, 31, 16, 17, 85], ["-", 0, 41, 64, 16, 31, 16, 31, 16, 12, 22], ["-", 12, 23, 0, 41, 64, 16, 31, 16, 17, 48], ["-", 31, 16, 12, 23, 0, 41, 64, 16, 12, 13], ["+", 31, 16, 12, 23, 0, 41, 64, 16, 12, 22]]
| 1
| 115
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RFOR(i, c) \
for (__typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a, b) make_pair(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &t) {
os << "[";
FOR(it, t) {
if (it != t.begin())
os << ",";
os << *it;
}
os << "]";
return os;
}
template <class T> ostream &operator<<(ostream &os, const set<T> &t) {
os << "{";
FOR(it, t) {
if (it != t.begin())
os << ",";
os << *it;
}
os << "}";
return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
return os << "(" << t.first << "," << t.second << ")";
}
const int INF = 1 << 28;
const double EPS = 1e-8;
const int MOD = 1000000007;
int n, m;
main() {
while (cin >> n >> m) {
priority_queue<pii> q;
ll sum = 0;
REP(i, n) {
int a, b;
cin >> a >> b;
q.emplace(b, a);
sum += a * b;
}
while (!q.empty() && m > 0) {
pii t = q.top();
q.pop();
sum -= t.first * min(m, t.second);
m -= t.second;
}
cout << sum << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RFOR(i, c) \
for (__typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a, b) make_pair(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &t) {
os << "[";
FOR(it, t) {
if (it != t.begin())
os << ",";
os << *it;
}
os << "]";
return os;
}
template <class T> ostream &operator<<(ostream &os, const set<T> &t) {
os << "{";
FOR(it, t) {
if (it != t.begin())
os << ",";
os << *it;
}
os << "}";
return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
return os << "(" << t.first << "," << t.second << ")";
}
const int INF = 1 << 28;
const double EPS = 1e-8;
const int MOD = 1000000007;
int n, m;
main() {
while (cin >> n >> m, n) {
priority_queue<pii> q;
ll sum = 0;
REP(i, n) {
int a, b;
cin >> a >> b;
q.emplace(b, a);
sum += a * b;
}
while (!q.empty() && m > 0) {
pii t = q.top();
q.pop();
sum -= t.first * min(m, t.second);
m -= t.second;
}
cout << sum << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
| 1
| 559
|
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
while (cin >> n >> m && n | m) {
vector<pair<int, int>> dp; // 期待値,距離
for (int i = 0; i < n; i++) {
int d, p;
cin >> d >> p;
dp.push_back(make_pair(p, d));
}
sort(dp.begin(), dp.end());
int ans = 0;
for (int i = n - 1; i >= 0; i--) {
if (m >= 0) {
if (dp[i].first <= m) {
m -= dp[i].second;
dp[i].second = 0;
} else if (dp[i].first > m) {
dp[i].second -= m;
m = 0;
}
}
ans = ans + dp[i].first * dp[i].second;
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
while (cin >> n >> m && n | m) {
vector<pair<int, int>> dp; // 期待値,距離
for (int i = 0; i < n; i++) {
int d, p;
cin >> d >> p;
dp.push_back(make_pair(p, d));
}
sort(dp.begin(), dp.end());
int ans = 0;
for (int i = n - 1; i >= 0; i--) {
if (m > 0) {
if (dp[i].second <= m) {
m -= dp[i].second;
dp[i].second = 0;
} else if (dp[i].second > m) {
dp[i].second -= m;
m = 0;
}
}
ans = ans + dp[i].first * dp[i].second;
}
cout << ans << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120]]
| 1
| 219
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
int n, m;
P x[10000];
void solve() {
rep(i, n) cin >> x[i].second >> x[i].first;
sort(x, x + n, greater<P>());
int ans = 0;
rep(i, n) {
if (m >= x[i].second) {
m -= x[i].second;
} else {
x[i].second -= m;
ans += x[i].second * x[i].first;
}
}
cout << ans << endl;
}
int main() {
while (cin >> n >> m) {
if (n == 0 && m == 0)
break;
solve();
}
}
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
int n, m;
P x[10000];
void solve() {
rep(i, n) cin >> x[i].second >> x[i].first;
sort(x, x + n, greater<P>());
int ans = 0;
rep(i, n) {
if (m >= x[i].second) {
m -= x[i].second;
} else {
x[i].second -= m;
m = 0;
ans += x[i].second * x[i].first;
}
}
cout << ans << endl;
}
int main() {
while (cin >> n >> m) {
if (n == 0 && m == 0)
break;
solve();
}
}
|
[["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
| 1
| 188
|
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
const int INF = (1 << 30) - 1;
int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int N, M;
while (cin >> N >> M, N | M) {
vector<pair<int, int>> d(N);
for (int i = 0; i < N; i++)
cin >> d[i].first >> d[i].second;
sort(d.rbegin(), d.rend());
int sum = 0;
for (int i = 0; i < N; i++) {
int x = min(M, d[i].first);
M -= x;
sum += d[i].second * (d[i].first - x);
}
cout << sum << endl;
}
return 0;
}
|
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
const int INF = (1 << 30) - 1;
int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int N, M;
while (cin >> N >> M, N | M) {
vector<pair<int, int>> d(N);
for (int i = 0; i < N; i++)
cin >> d[i].second >> d[i].first;
sort(d.rbegin(), d.rend());
int sum = 0;
for (int i = 0; i < N; i++) {
int x = min(M, d[i].second);
M -= x;
sum += d[i].first * (d[i].second - x);
}
cout << sum << endl;
}
return 0;
}
|
[["-", 8, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["+", 8, 1, 0, 16, 31, 16, 12, 118, 119, 120], ["-", 0, 7, 8, 1, 0, 16, 12, 118, 119, 120], ["+", 0, 7, 8, 1, 0, 16, 12, 118, 119, 120], ["-", 49, 50, 51, 2, 3, 4, 0, 118, 119, 120], ["+", 49, 50, 51, 2, 3, 4, 0, 118, 119, 120], ["-", 0, 1, 0, 11, 12, 16, 31, 118, 119, 120], ["+", 0, 1, 0, 11, 12, 16, 31, 118, 119, 120], ["-", 12, 16, 12, 23, 0, 16, 31, 118, 119, 120], ["+", 12, 16, 12, 23, 0, 16, 31, 118, 119, 120]]
| 1
| 195
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int N;
long long int M;
while (1) {
cin >> N >> M;
if (N == 0 && M == 0)
break;
int D[10002][2] = {};
int P[10001] = {};
for (int i = 0; i < N; i++)
cin >> D[i][0] >> D[i][1];
int c = 0;
for (int i = 0; i < N; i++)
for (int j = N - 1; j > i; j--) {
if (D[j][1] > D[j - 1][1]) {
int t = D[j][1];
D[j][1] = D[j - 1][1];
D[j - 1][1] = t;
int T = D[j][0];
D[j][0] = D[j - 1][1];
D[j - 1][0] = T;
}
}
for (int i = 0; i < N; i++)
if (D[i][0] > 0) {
if (M >= D[i][0]) {
M -= D[i][0];
D[i][0] = 0;
} else {
D[i][0] -= M;
M = 0;
}
}
for (int i = 0; i < N; i++)
c += D[i][1] * D[i][0];
cout << c << endl;
}
return 0;
}
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int N;
long long int M;
while (1) {
cin >> N >> M;
if (N == 0 && M == 0)
break;
int D[10002][2] = {};
int P[10001] = {};
for (int i = 0; i < N; i++)
cin >> D[i][0] >> D[i][1];
int c = 0;
for (int i = 0; i < N; i++)
for (int j = N - 1; j > i; j--) {
if (D[j][1] > D[j - 1][1]) {
int t = D[j][1];
D[j][1] = D[j - 1][1];
D[j - 1][1] = t;
int T = D[j][0];
D[j][0] = D[j - 1][0];
D[j - 1][0] = T;
}
}
for (int i = 0; i < N; i++)
if (D[i][0] > 0) {
if (M >= D[i][0]) {
M -= D[i][0];
D[i][0] = 0;
} else {
D[i][0] -= M;
M = 0;
}
}
for (int i = 0; i < N; i++)
c += D[i][1] * D[i][0];
cout << c << endl;
}
return 0;
}
|
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13]]
| 1
| 360
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
inline ll toInt(string s) {
ll v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
template <class T> inline T sqr(T x) { return x * x; }
#define For(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) For(i, 0, n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (sizeof(a))
#define Fill(a, v) fill((int *)a, (int *)(a + (sz(a) / sz(*(a)))), v)
bool cheak(int x, int y, int xMax, int yMax) {
return x >= 0 && y >= 0 && xMax > x && yMax > y;
}
const int dx[3] = {-1, -1, 0}, dy[3] = {-1, 0, -1};
const int mod = 1000000007;
const int INF = 1e9;
ll n, m;
int main() {
while (cin >> n >> m && (n || m)) {
const int M = 10001;
P dp[M];
rep(i, n) { cin >> dp[i].second >> dp[i].first; }
sort(dp, dp + m, greater<P>());
ll ans = 0;
rep(i, n) {
if (m) {
if (m >= dp[i].second) {
m -= dp[i].second;
} else {
ans += (dp[i].second - m) * dp[i].first;
m = 0;
}
} else {
ans += dp[i].second * dp[i].first;
}
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
inline ll toInt(string s) {
ll v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
template <class T> inline T sqr(T x) { return x * x; }
#define For(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) For(i, 0, n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (sizeof(a))
#define Fill(a, v) fill((int *)a, (int *)(a + (sz(a) / sz(*(a)))), v)
bool cheak(int x, int y, int xMax, int yMax) {
return x >= 0 && y >= 0 && xMax > x && yMax > y;
}
const int dx[3] = {-1, -1, 0}, dy[3] = {-1, 0, -1};
const int mod = 1000000007;
const int INF = 1e9;
ll n, m;
int main() {
while (cin >> n >> m && n) {
const int M = 10001;
P dp[M];
rep(i, n) { cin >> dp[i].second >> dp[i].first; }
sort(dp, dp + n, greater<P>());
ll ans = 0;
rep(i, n) {
if (m) {
if (m >= dp[i].second) {
m -= dp[i].second;
} else {
ans += (dp[i].second - m) * dp[i].first;
m = 0;
}
} else {
ans += dp[i].second * dp[i].first;
}
}
cout << ans << endl;
}
return 0;
}
|
[["-", 0, 52, 15, 339, 51, 16, 12, 23, 0, 24], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 52, 15, 339, 51, 16, 12, 23, 0, 25], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
| 1
| 433
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long N, M;
while (cin >> N >> M && N != 0 && M != 0) {
vector<pair<int, int>> dp(N);
long long ans = 0;
for (int i = 0; i < N; i++) {
cin >> dp[i].second >> dp[i].first;
ans += dp[i].second * dp[i].first;
}
sort(dp.begin(), dp.end());
reverse(dp.begin(), dp.end());
for (int i = 0; i < N; i++) {
if (M <= 0)
break;
if (M >= dp[i].second) {
M -= dp[i].second;
ans -= dp[i].second * dp[i].first;
} else {
ans -= M * dp[i].first;
M = 0;
}
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long N, M;
while (cin >> N >> M && N != 0 || M != 0) {
vector<pair<int, int>> dp(N);
long long ans = 0;
for (int i = 0; i < N; i++) {
cin >> dp[i].second >> dp[i].first;
ans += dp[i].second * dp[i].first;
}
sort(dp.begin(), dp.end());
reverse(dp.begin(), dp.end());
for (int i = 0; i < N; i++) {
if (M <= 0)
break;
if (M >= dp[i].second) {
M -= dp[i].second;
ans -= dp[i].second * dp[i].first;
} else {
ans -= M * dp[i].first;
M = 0;
}
}
cout << ans << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 106]]
| 1
| 226
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int main() {
int n, money;
while (cin >> n >> money && n > 0 && money > 0) {
pair<int, int> PD[10010];
int p, d;
for (int i = 0; i < n; i++) {
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort(PD, PD + n);
int need;
int ans = 0;
for (int i = 0; i < n; i++) {
need = i;
if (PD[n - 1 - i].second <= money) {
money -= PD[n - 1 - i].second;
} else {
ans += PD[n - 1 - i].first * (PD[n - 1 - i].second - money);
break;
}
}
for (int j = 0; j < n - 1 - need; j++) {
ans += PD[j].first * PD[j].second;
}
cout << ans << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int main() {
int n, money;
while (cin >> n >> money && (n > 0 || money > 0)) {
pair<int, int> PD[10010];
int p, d;
for (int i = 0; i < n; i++) {
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort(PD, PD + n);
int need;
int ans = 0;
for (int i = 0; i < n; i++) {
need = i;
if (PD[n - 1 - i].second <= money) {
money -= PD[n - 1 - i].second;
} else {
ans += PD[n - 1 - i].first * (PD[n - 1 - i].second - money);
break;
}
}
for (int j = 0; j < n - 1 - need; j++) {
ans += PD[j].first * PD[j].second;
}
cout << ans << endl;
}
}
|
[["+", 0, 52, 15, 339, 51, 16, 12, 23, 0, 24], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["+", 0, 52, 15, 339, 51, 16, 12, 23, 0, 25]]
| 1
| 231
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int n, m;
int kitaichi(pair<int, int> *pd, int size) {
int sum = 0;
for (int i = 0; i < n; i++) {
sum += pd[i].first * pd[i].second;
}
return sum;
}
int solve() {
pair<int, int> pd[10000];
for (int i = 0; i < n; i++) {
int d, p;
cin >> d >> p;
pd[i] = make_pair(p, d);
}
sort(pd, pd + n);
reverse(pd, pd + n);
int e = kitaichi(pd, n);
int current = 0;
while (m > 0 && current < n - 1) {
if (pd[current].second < m) {
m -= pd[current].second;
e -= pd[current].second * pd[current].first;
current++;
} else {
e -= m * pd[current].first;
break;
}
}
if (current > n - 1)
e = 0;
return e;
}
int main() {
while (cin >> n >> m && n != 0) {
cout << solve() << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int n, m;
int kitaichi(pair<int, int> *pd, int size) {
int sum = 0;
for (int i = 0; i < n; i++) {
sum += pd[i].first * pd[i].second;
}
return sum;
}
int solve() {
pair<int, int> pd[10000];
for (int i = 0; i < n; i++) {
int d, p;
cin >> d >> p;
pd[i] = make_pair(p, d);
}
sort(pd, pd + n);
reverse(pd, pd + n);
int e = kitaichi(pd, n);
int current = 0;
while (m > 0 && current <= n - 1) {
if (pd[current].second < m) {
m -= pd[current].second;
e -= pd[current].second * pd[current].first;
current++;
} else {
e -= m * pd[current].first;
break;
}
}
if (current > n - 1)
e = 0;
return e;
}
int main() {
while (cin >> n >> m && n != 0) {
cout << solve() << endl;
}
}
|
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 19]]
| 1
| 275
|
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>
typedef std::int_fast32_t s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t s64;
typedef std::uint_fast64_t u64;
const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);
typedef std::pair<int, int> pii;
template <typename T> void print_array(T *A_, s32 size) {
// printf("%d\n", size);
if (size != 0) {
for (int i = 0; i < size - 1; ++i) {
printf("%d ", A_[i]);
}
printf("%d\n", A_[size - 1]);
}
}
auto main() -> int {
for (;;) {
int n, m;
std::cin >> n >> m;
if (n == 0 and m == 0)
break;
std::vector<pii> vpii;
for (int i = 0; i < n; ++i) {
int d, p;
std::cin >> d >> p;
vpii.push_back(pii(p, d));
}
std::sort(vpii.begin(), vpii.end());
std::reverse(vpii.begin(), vpii.end());
int res = 0;
for (int i = 0; i < n; ++i) {
if (vpii[i].second <= m) {
m -= vpii[i].second;
} else {
res += (vpii[i].second - m) * vpii[i].first;
for (int j = i + 1; j < n; ++j) {
res += vpii[i].first * vpii[i].second;
}
break;
}
}
std::cout << res << std::endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>
typedef std::int_fast32_t s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t s64;
typedef std::uint_fast64_t u64;
const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);
typedef std::pair<int, int> pii;
template <typename T> void print_array(T *A_, s32 size) {
// printf("%d\n", size);
if (size != 0) {
for (int i = 0; i < size - 1; ++i) {
printf("%d ", A_[i]);
}
printf("%d\n", A_[size - 1]);
}
}
auto main() -> int {
for (;;) {
int n, m;
std::cin >> n >> m;
if (n == 0 and m == 0)
break;
std::vector<pii> vpii;
for (int i = 0; i < n; ++i) {
int d, p;
std::cin >> d >> p;
vpii.push_back(pii(p, d));
}
std::sort(vpii.begin(), vpii.end());
std::reverse(vpii.begin(), vpii.end());
int res = 0;
for (int i = 0; i < n; ++i) {
if (vpii[i].second <= m) {
m -= vpii[i].second;
} else {
res += (vpii[i].second - m) * vpii[i].first;
for (int j = i + 1; j < n; ++j) {
res += vpii[j].first * vpii[j].second;
}
break;
}
}
std::cout << res << std::endl;
}
return 0;
}
|
[["-", 12, 16, 31, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 118, 28, 69, 341, 342, 0, 22], ["-", 12, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 12, 118, 28, 69, 341, 342, 0, 22]]
| 1
| 373
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n_intervals, budget;
// read in number of intervals, and budget
cin >> n_intervals >> budget;
// pair with probability of attack and distance (of each interval)
pair<int, int> PD[10010];
int p, d;
while (n_intervals != 0 && budget != 0) { // while not end of input
for (int i = 0; i < n_intervals; i++) {
// read distance and probability
cin >> d >> p;
PD[i] = make_pair(p, d); // store in array
}
// sort the array ascending order
sort(PD, PD + n_intervals);
reverse(PD, PD + n_intervals);
int i = 0;
while (budget > PD[i].second && i < n_intervals) {
// while budget bigger than distance of current interval
budget -= PD[i++].second; // subtract from budget
// traverse array from biggest probability to smallest
}
if (i < n_intervals) {
PD[i].second -=
budget; // subtract from current interval budget (remainder)
}
int sum = 0; // sum of expected attacks
for (; i < n_intervals; i++) {
sum += PD[i].first * PD[i].second;
}
cout << sum << endl; // print output
cin >> n_intervals >> budget; // read new input
}
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n_intervals, budget;
// read in number of intervals, and budget
cin >> n_intervals >> budget;
// pair with probability of attack and distance (of each interval)
pair<int, int> PD[10010];
int p, d;
while (!(n_intervals == 0 && budget == 0)) { // while not end of input
for (int i = 0; i < n_intervals; i++) {
// read distance and probability
cin >> d >> p;
PD[i] = make_pair(p, d); // store in array
}
// sort the array in descending order
sort(PD, PD + n_intervals);
reverse(PD, PD + n_intervals);
int i = 0;
while (budget > PD[i].second && i < n_intervals) {
// while budget bigger than distance of current interval
budget -= PD[i++].second; // subtract from budget
}
if (i < n_intervals) {
PD[i].second -=
budget; // subtract from current interval budget (remainder)
}
int sum = 0; // sum of expected attacks
for (; i < n_intervals; i++) {
sum += PD[i].first * PD[i].second;
}
cout << sum << endl; // print output
cin >> n_intervals >> budget; // read new input
}
return 0;
}
|
[["+", 8, 9, 0, 52, 15, 339, 51, 91, 17, 111], ["+", 0, 52, 15, 339, 51, 91, 28, 23, 0, 24], ["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 51, 91, 28, 23, 0, 16, 31, 16, 17, 60], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 51, 91, 28, 23, 0, 16, 12, 16, 17, 60], ["+", 0, 52, 15, 339, 51, 91, 28, 23, 0, 25]]
| 1
| 215
|
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
int n, m, d, p, o;
typedef pair<int, int> ma;
int i, j, k;
cin >> n >> m;
while (n != 0 && m != 0) {
vector<ma> map;
ma b;
for (i = 0; i < n; i++) {
cin >> d >> p;
b.first = p;
b.second = d;
map.push_back(b);
}
sort(map.begin(), map.end(), greater<ma>());
o = 0;
for (i = 0; i < map.size(); i++) {
if (m >= map[i].second)
m -= map[i].second;
else if (m > 0) {
o += (map[i].second - m) * map[i].first;
m = 0;
} else
o += map[i].first * map[i].second;
}
cout << o << endl;
cin >> n >> m;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
int n, m, d, p, o;
typedef pair<int, int> ma;
int i, j, k;
cin >> n >> m;
while (n != 0 || m != 0) {
vector<ma> map;
ma b;
for (i = 0; i < n; i++) {
cin >> d >> p;
b.first = p;
b.second = d;
map.push_back(b);
}
sort(map.begin(), map.end(), greater<ma>());
o = 0;
for (i = 0; i < map.size(); i++) {
if (m >= map[i].second)
m -= map[i].second;
else if (m > 0) {
o += (map[i].second - m) * map[i].first;
m = 0;
} else
o += map[i].first * map[i].second;
}
cout << o << endl;
cin >> n >> m;
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 106]]
| 1
| 242
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while (cin >> n >> m && (n || m)) {
vector<pair<int, int>> dp;
for (int i = 0; i < n; ++i) {
int d, p;
cin >> d >> p;
dp.push_back(make_pair(p, d));
}
sort(dp.begin(), dp.end(), greater<pair<int, int>>());
int s = 0;
for (int i = 0; i < n; ++i) {
s += dp[i].first * dp[i].second;
for (int i = 0; i < n; ++i) {
int guarded = min(m, dp[i].second);
s -= dp[i].first * guarded;
m -= guarded;
}
}
cout << s << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
while (cin >> n >> m && (n || m)) {
vector<pair<int, int>> dp;
for (int i = 0; i < n; ++i) {
int d, p;
cin >> d >> p;
dp.push_back(make_pair(p, d));
}
sort(dp.begin(), dp.end(), greater<pair<int, int>>());
int s = 0;
for (int i = 0; i < n; ++i) {
s += dp[i].first * dp[i].second;
}
for (int i = 0; i < n; ++i) {
int guarded = min(m, dp[i].second);
s -= dp[i].first * guarded;
m -= guarded;
}
cout << s << endl;
}
}
|
[["+", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
| 1
| 199
|
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
vector<pii> ans;
int main() {
while (1) {
int N, M;
cin >> N >> M;
if (!N)
break;
ans.clear();
for (int i = 0; i < N; i++) {
int d, p;
cin >> d >> p;
ans.push_back(pii(p, d));
}
sort(ans.begin(), ans.end());
long long sum = 0;
while (M > 0) {
int id = ans.size() - 1;
if (M > ans[id].second) {
M -= ans[id].second;
ans.pop_back();
} else if (M > 0) {
ans[id].second -= M;
M = 0;
}
}
for (auto x : ans) {
sum += x.first * x.second;
}
cout << sum << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
vector<pii> ans;
int main() {
while (1) {
int N, M;
cin >> N >> M;
if (!N)
break;
ans.clear();
for (int i = 0; i < N; i++) {
int d, p;
cin >> d >> p;
ans.push_back(pii(p, d));
}
sort(ans.begin(), ans.end());
long long sum = 0;
while (M > 0 and ans.size()) {
int id = ans.size() - 1;
if (M > ans[id].second) {
M -= ans[id].second;
ans.pop_back();
} else if (M > 0) {
ans[id].second -= M;
M = 0;
}
}
for (auto x : ans) {
sum += x.first * x.second;
}
cout << sum << endl;
}
}
|
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 355], ["+", 15, 339, 51, 16, 12, 2, 63, 118, 28, 22], ["+", 15, 339, 51, 16, 12, 2, 63, 118, 17, 131], ["+", 15, 339, 51, 16, 12, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 12, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 12, 2, 3, 4, 0, 25]]
| 1
| 211
|
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main() {
int N, M, D, P;
while (cin >> N >> M, N || M) {
vector<int> dp(11);
for (int i = 0; i < N; i++) {
cin >> D >> P;
dp[P] += D;
}
int res = 0;
for (int i = 10; i >= 0; i--) {
if (dp[i] < M) {
M -= dp[i];
} else {
res += (dp[i] - M) * i;
}
}
cout << res << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main() {
int N, M, D, P;
while (cin >> N >> M, N || M) {
vector<int> dp(11);
for (int i = 0; i < N; i++) {
cin >> D >> P;
dp[P] += D;
}
int res = 0;
for (int i = 10; i >= 0; i--) {
if (dp[i] < M) {
M -= dp[i];
} else {
res += (dp[i] - M) * i;
M = 0;
}
}
cout << res << endl;
}
return 0;
}
|
[["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
| 1
| 143
|
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define FOR(i, k, n) for (int(i) = (k); (i) < (n); ++(i))
#define rep(i, n) FOR(i, 0, n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template <class T> using vv = vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;
int main() {
while (1) {
int n;
ull m;
i_i d[10000];
cin >> n >> m;
if (n == 0) {
break;
}
int sum = 0;
rep(i, n) {
cin >> d[i].first >> d[i].second;
sum += d[i].first * d[i].second;
}
sort(begin(d), &d[n], [](i_i p, i_i q) { return p.second > q.second; });
for (int i = 0; m > 0; i++) {
if (i == n) {
break;
}
if (m > (ull)d[i].second) {
sum -= d[i].first * d[i].second;
m -= (ull)d[i].first;
} else {
sum -= (ull)d[i].second * m;
m = 0;
}
}
cout << sum << endl;
}
return 0;
}
|
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define FOR(i, k, n) for (int(i) = (k); (i) < (n); ++(i))
#define rep(i, n) FOR(i, 0, n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template <class T> using vv = vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;
int main() {
while (1) {
int n;
ull m;
i_i d[10050];
cin >> n >> m;
if (n == 0) {
break;
}
int sum = 0;
rep(i, n) {
cin >> d[i].first >> d[i].second;
sum += d[i].first * d[i].second;
}
sort(begin(d), &d[n], [](i_i p, i_i q) { return p.second > q.second; });
for (int i = 0; m > 0; i++) {
if (i == n) {
break;
}
if (m > (ull)d[i].first) {
sum -= d[i].first * d[i].second;
m -= (ull)d[i].first;
} else {
sum -= (ull)d[i].second * m;
m = 0;
}
}
cout << sum << endl;
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 15, 339, 51, 16, 12, 74, 51, 118, 119, 120], ["+", 15, 339, 51, 16, 12, 74, 51, 118, 119, 120]]
| 1
| 372
|
#include "bits/stdc++.h"
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(x) cout << #x << " : " << x << " ------------"
using namespace std;
using Info = tuple<int, int>;
int main() {
int n, m;
while (cin >> n >> m, n && m) {
vector<Info> sections;
int ev = 0;
rep(i, n) {
int d, p;
cin >> d >> p;
sections.pb(Info(p, d));
ev += d * p;
}
sort(all(sections), greater<Info>());
for (auto s : sections) {
int d = get<1>(s), p = get<0>(s);
ev -= min(m, d) * p;
m -= d;
if (m <= 0)
break;
else if (ev < 0) {
ev = 0;
break;
}
}
cout << ev << endl;
}
return EXIT_SUCCESS;
}
|
#include "bits/stdc++.h"
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(x) cout << #x << " : " << x << " ------------"
using namespace std;
using Info = tuple<int, int>;
int main() {
int n, m;
while (cin >> n >> m, n | m) {
vector<Info> sections;
int ev = 0;
rep(i, n) {
int d, p;
cin >> d >> p;
sections.pb(Info(p, d));
ev += d * p;
}
sort(all(sections), greater<Info>());
for (auto s : sections) {
int d = get<1>(s), p = get<0>(s);
ev -= min(m, d) * p;
m -= d;
if (m <= 0)
break;
else if (ev < 0) {
ev = 0;
break;
}
}
cout << ev << endl;
}
return EXIT_SUCCESS;
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 139]]
| 1
| 206
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;
P h[100000];
int main() {
int n, m;
while (scanf("%d%d", &n, &m), n) {
int ans = 0;
rep(i, n) {
int d, p;
scanf("%d%d", &d, &p);
ans += d * p;
h[i] = P(p, d);
}
sort(h, h + n, greater<>());
int sum = m;
int i;
for (i = 0; i < n && sum - h[i].second >= 0; i++) {
sum -= h[i].second;
ans -= h[i].first * h[i].second;
}
ans -= h[i].first * sum;
printf("%d\n", min(0, ans));
}
}
|
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;
P h[100000];
int main() {
int n, m;
while (scanf("%d%d", &n, &m), n) {
int ans = 0;
rep(i, n) {
int d, p;
scanf("%d%d", &d, &p);
ans += d * p;
h[i] = P(p, d);
}
sort(h, h + n, greater<>());
int sum = m;
int i;
for (i = 0; i < n && sum - h[i].second >= 0; i++) {
sum -= h[i].second;
ans -= h[i].first * h[i].second;
}
ans -= h[i].first * sum;
printf("%d\n", max(0, ans));
}
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22]]
| 1
| 208
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for (int(i) = (a)-1; (i) >= 0; (i)--)
#define FORR(i, a, b) for (int(i) = (a)-1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
#define int LL
void solve(int n, int m) {
VPII PD(n);
REP(i, n) {
int d, p;
cin >> d >> p;
PD[i] = MP(p, d);
}
RSORT(PD);
int ans = 0;
FORE(el, PD) {
if (el.second <= m) {
m -= el.second;
} else if (m != 0) {
ans += (el.second - m) * el.first;
m = 0;
} else {
ans += el.second * el.first;
}
}
cout << ans << endl;
}
signed main(void) {
int n, m, p, a, b, c, x, y, z, q;
string s;
while (cin >> n >> m, n && m) {
solve(n, m);
// return 0;
}
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for (int(i) = (a)-1; (i) >= 0; (i)--)
#define FORR(i, a, b) for (int(i) = (a)-1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
#define int LL
void solve(int n, int m) {
VPII PD(n);
REP(i, n) {
int d, p;
cin >> d >> p;
PD[i] = MP(p, d);
}
RSORT(PD);
int ans = 0;
FORE(el, PD) {
if (el.second <= m) {
m -= el.second;
} else if (m != 0) {
ans += (el.second - m) * el.first;
m = 0;
} else {
ans += el.second * el.first;
}
}
cout << ans << endl;
}
signed main(void) {
int n, m, p, a, b, c, x, y, z, q;
string s;
while (cin >> n >> m, n) {
solve(n, m);
// return 0;
}
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["-", 0, 52, 15, 339, 51, 34, 12, 16, 12, 22]]
| 1
| 448
|
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
class load {
public:
llong d, p;
bool operator<(const load &other) { return this->p > other.p; }
};
int main() {
int n, m;
while (cin >> n >> m, m) {
vector<load> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].d >> v[i].p;
}
sort(v.begin(), v.end());
llong ans = 0;
for (int i = 0; i < n; i++) {
if (m - v[i].d >= 0) {
m -= v[i].d;
v[i].d = 0;
} else {
v[i].d -= m;
break;
}
}
for (int i = 0; i < n; i++) {
ans += v[i].d * v[i].p;
}
cout << ans << endl;
}
return 0;
}
|
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
class load {
public:
int d, p;
bool operator<(const load &other) { return this->p > other.p; }
};
int main() {
int n, m;
while (cin >> n >> m, n) {
vector<load> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].d >> v[i].p;
}
sort(v.begin(), v.end());
int ans = 0;
for (int i = 0; i < n; i++) {
if (m - v[i].d >= 0) {
m -= v[i].d;
v[i].d = 0;
} else {
v[i].d -= m;
break;
}
}
for (int i = 0; i < n; i++) {
ans += v[i].d * v[i].p;
}
cout << ans << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 353, 8, 123, 0, 124, 39, 78], ["+", 0, 30, 0, 353, 8, 123, 0, 124, 39, 40], ["-", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40]]
| 1
| 238
|
#include <bits/stdc++.h>
#define REP(i, n, N) for (int i = n; i < N; i++)
#define p(S) cout << S << endl
using namespace std;
int main() {
int N, M;
while (cin >> N >> M && N && M) {
int P[11] = {0};
int d, p;
long long int ans = 0;
REP(i, 0, N) {
cin >> d >> p;
P[p] += d;
}
for (int i = 10; i >= 0; i--) {
if (P[i] >= M) {
P[i] -= M;
break;
} else {
M -= P[i];
P[i] = 0;
}
}
REP(i, 1, 11) { ans += i * P[i]; }
p(ans);
}
return 0;
}
|
#include <bits/stdc++.h>
#define REP(i, n, N) for (int i = n; i < N; i++)
#define p(S) cout << S << endl
using namespace std;
int main() {
int N, M;
while (cin >> N >> M && N) {
int P[11] = {0};
int d, p;
long long int ans = 0;
REP(i, 0, N) {
cin >> d >> p;
P[p] += d;
}
for (int i = 10; i >= 0; i--) {
if (P[i] >= M) {
P[i] -= M;
break;
} else {
M -= P[i];
P[i] = 0;
}
}
REP(i, 1, 11) { ans += i * P[i]; }
p(ans);
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
| 1
| 174
|
#include <stdio.h>
int main(void) {
int a, b, n, m, k, p[11];
while (scanf("%d %d", &n, &m) != EOF) {
k = 0;
for (int i = 0; i < 11; i++)
p[i] = 0;
while (n--) {
scanf("%d %d", &a, &b);
p[b] += a;
}
for (int i = 10; i >= 0; i--) {
if (m >= p[i]) {
m -= p[i];
p[i] = 0;
} else {
p[i] -= m;
m = 0;
break;
}
}
for (int i = 1; i < 11; i++)
k += p[i] * i;
printf("%d\n", k);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int a, b, n, m, k, p[11];
while (scanf("%d %d", &n, &m), n || m) {
k = 0;
for (int i = 0; i < 11; i++)
p[i] = 0;
while (n--) {
scanf("%d %d", &a, &b);
p[b] += a;
}
for (int i = 10; i >= 0; i--) {
if (m >= p[i]) {
m -= p[i];
p[i] = 0;
} else {
p[i] -= m;
m = 0;
break;
}
}
for (int i = 1; i < 11; i++)
k += p[i] * i;
printf("%d\n", k);
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 12, 22]]
| 1
| 189
|
#include <bits/stdc++.h>
using namespace std;
/*{{{*/ // template
#define REP(i, n) for (int i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1 << 29
#define LINF LLONG_MAX / 3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr << #x << ":" << x << endl
#define debug2(x, y) cerr << #x << "," << #y ":" << x << "," << y << endl
// struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double {
double d;
explicit Double(double x) : d(x) {}
};
ostream &operator<<(ostream &os, const Double x) {
os << fixed << setprecision(20) << x.d;
return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
constexpr double eps = 1e-14;
constexpr ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
/*}}}*/
int N, M;
void solve() {
ll cost[16] = {};
for (int i = 0; i < N; i++) {
ll d, p;
cin >> d >> p;
cost[p] += d;
}
ll ans = 0;
for (int i = 10; i >= 0; i--) {
if (cost[i] <= M) {
M -= cost[i];
} else {
cost[i] -= M;
ans += i * cost[i];
}
}
cout << ans << endl;
}
int main() {
while (cin >> N >> M) {
if (N == 0 && M == 0)
break;
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
/*{{{*/ // template
#define REP(i, n) for (int i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1 << 29
#define LINF LLONG_MAX / 3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr << #x << ":" << x << endl
#define debug2(x, y) cerr << #x << "," << #y ":" << x << "," << y << endl
// struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double {
double d;
explicit Double(double x) : d(x) {}
};
ostream &operator<<(ostream &os, const Double x) {
os << fixed << setprecision(20) << x.d;
return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
constexpr double eps = 1e-14;
constexpr ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
/*}}}*/
ll N, M;
void solve() {
ll cost[16] = {};
for (int i = 0; i < N; i++) {
ll d, p;
cin >> d >> p;
cost[p] += d;
}
ll ans = 0;
for (int i = 10; i >= 0; i--) {
if (cost[i] <= M) {
M -= cost[i];
} else {
cost[i] -= M;
ans += i * cost[i];
M = 0;
}
}
cout << ans << endl;
}
int main() {
while (cin >> N >> M) {
if (N == 0 && M == 0)
break;
solve();
}
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13]]
| 1
| 499
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
void calc_danger(int res, int i, pair<int, int> b[], int n) {
int danger = 0;
danger += res * (-1) * b[i].first;
for (int j = 0; j < i; j++) {
danger += b[j].first * b[j].second;
}
cout << danger << endl;
return;
}
int main() {
int n, m;
int danger;
while (cin >> n >> m) {
if (n == 0 && m == 0)
break;
int d[n], p[n];
pair<int, int> b[n];
for (int i = 0; i < n; i++) {
cin >> d[i] >> p[i];
b[i] = make_pair(p[i], d[i]);
}
sort(b, b + n);
int res = m;
for (int i = n - 1; i >= 0; i--) {
res = res - b[i].second;
if (res <= 0) {
calc_danger(res, i, b, n);
break;
} else if (i == n - 1) {
cout << 0 << endl;
}
}
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
void calc_danger(int res, int i, pair<int, int> b[], int n) {
int danger = 0;
danger += res * (-1) * b[i].first;
for (int j = 0; j < i; j++) {
danger += b[j].first * b[j].second;
}
cout << danger << endl;
return;
}
int main() {
int n, m;
int danger;
while (cin >> n >> m) {
if (n == 0 && m == 0)
break;
int d[n], p[n];
pair<int, int> b[n];
for (int i = 0; i < n; i++) {
cin >> d[i] >> p[i];
b[i] = make_pair(p[i], d[i]);
}
sort(b, b + n);
int res = m;
for (int i = n - 1; i >= 0; i--) {
res = res - b[i].second;
if (res <= 0) {
calc_danger(res, i, b, n);
break;
} else if (i == 0) {
cout << 0 << endl;
}
}
}
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 282
|
// princess marriage1
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int main() {
pair<int, int> road[20000];
int i, n, money, a, b, j = 0, kitai = 0;
cin >> n; // road????????°
cin >> money; // money
while (n != 0 || money != 0) {
for (i = 0; i < n; i++) {
cin >> a >> b;
road[i] = make_pair(b, a);
kitai += a * b; //[][1]???????????????[][2]???????????????
};
sort(road, road + n);
reverse(road, road + n);
while (money > 0) {
if (money >= road[j].second) {
money -= road[j].second;
kitai -= road[j].first * road[j].second;
j++;
} else {
kitai -= road[j].first * money;
money = 0;
};
};
cout << kitai << endl;
cin >> n >> money;
kitai = 0;
j = 0; //????????????????????????????????????????????¨????????°???????????????????????????(????????§30????????????)
};
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int main() {
pair<int, int> road[20000];
int i, n, money, a, b, j = 0, kitai = 0;
cin >> n; // road????????°
cin >> money; // money
while (n != 0 || money != 0) {
for (i = 0; i < n; i++) {
cin >> a >> b;
road[i] = make_pair(b, a);
kitai += a * b; //[][1]???????????????[][2]???????????????
};
sort(road, road + n);
reverse(road, road + n);
while (money > 0 && kitai > 0) {
if (money >= road[j].second) {
money -= road[j].second;
kitai -= road[j].first * road[j].second;
j++;
} else {
kitai -= road[j].first * money;
money = 0;
};
};
cout << kitai << endl;
cin >> n >> money;
kitai = 0;
j = 0; //????????????????????????????????????????????¨????????°???????????????????????????(????????§30????????????)
};
return 0;
}
|
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 222
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int main() {
int N, M;
while (cin >> N >> M && N != 0 && M != 0) {
pair<int, int> *road = new pair<int, int>[N];
for (int i = 0; i < N; ++i) {
cin >> road[i].second >> road[i].first; //(P,D)
}
sort(road, road + N);
reverse(road, road + N);
for (int i = 0; i < N; ++i) {
if (M == 0)
break;
int deduct = (road[i].second <= M ? road[i].second : M);
road[i].second -= deduct;
M -= deduct;
}
int S = 0;
for (int i = 0; i < N; ++i) {
S += road[i].first * road[i].second;
}
cout << S << "\n";
delete[] road;
}
}
|
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
int main() {
int N, M;
while (cin >> N >> M && !(N == 0 && M == 0)) {
pair<int, int> *road = new pair<int, int>[N];
for (int i = 0; i < N; ++i) {
cin >> road[i].second >> road[i].first; //(P,D)
}
sort(road, road + N);
reverse(road, road + N);
for (int i = 0; i < N; ++i) {
if (M == 0)
break;
int deduct = (road[i].second <= M ? road[i].second : M);
road[i].second -= deduct;
M -= deduct;
}
int S = 0;
for (int i = 0; i < N; ++i) {
S += road[i].first * road[i].second;
}
cout << S << "\n";
delete[] road;
}
}
|
[["+", 0, 52, 15, 339, 51, 16, 12, 91, 17, 111], ["+", 15, 339, 51, 16, 12, 91, 28, 23, 0, 24], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 79], ["+", 12, 91, 28, 23, 0, 16, 31, 16, 17, 60], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 12, 91, 28, 23, 0, 16, 12, 16, 17, 60], ["+", 15, 339, 51, 16, 12, 91, 28, 23, 0, 25]]
| 1
| 220
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
using namespace std;
int main() {
int N, M;
pair<int, int> PD[10010];
while (cin >> N >> M && N > 0) {
int d, p;
for (int i = 0; i < N; i++) {
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort(PD, PD + N);
reverse(PD, PD + N);
int S = 0;
for (int j = 0; j < N; j++) {
S += PD[j].first * PD[j].second;
}
for (int k = 0; k < N; k++) {
if (M <= 0)
break;
int guarded = min(M, PD[k].second);
S -= PD[k].first * guarded;
M -= guarded;
}
cout << S;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
using namespace std;
int main() {
int N, M;
pair<int, int> PD[10010];
while (cin >> N >> M && N > 0) {
int d, p;
for (int i = 0; i < N; i++) {
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort(PD, PD + N);
reverse(PD, PD + N);
int S = 0;
for (int j = 0; j < N; j++) {
S += PD[j].first * PD[j].second;
}
for (int k = 0; k < N; k++) {
if (M <= 0)
break;
int guarded = min(M, PD[k].second);
S -= PD[k].first * guarded;
M -= guarded;
}
cout << S << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 203
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
//-----------------------------------------------------------------------
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
while (cin >> n >> m, n | m) {
int cnt[11] = {0};
int sum = 0;
REP(i, n) {
int d, p;
cin >> d >> p;
cnt[p] += d;
sum += d;
}
if (m >= sum)
cout << 0 << endl;
else {
int ans = 0;
int rest = sum - m;
for (int i = 1; i <= 10; i++) {
if (rest > cnt[i])
rest -= cnt[i], ans += i * cnt[i];
else {
ans += i * rest;
break;
}
}
cout << ans << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
//-----------------------------------------------------------------------
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
while (cin >> n >> m, n | m) {
int cnt[11] = {0};
int sum = 0;
REP(i, n) {
int d, p;
cin >> d >> p;
cnt[p] += d;
sum += d;
}
if (m >= sum)
cout << 0 << endl;
else {
int ans = 0;
int rest = sum - m;
for (int i = 0; i <= 10; i++) {
if (rest > cnt[i])
rest -= cnt[i], ans += i * cnt[i];
else {
ans += i * rest;
break;
}
}
cout << ans << endl;
}
}
}
|
[["-", 0, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
| 1
| 207
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
int main() {
ll n, m;
while (cin >> n >> m, n + m) {
ll ans = 0;
vector<pair<int, int>> pii(n);
for (int i = 0; i < n; i++) {
cin >> pii[i].S >> pii[i].F;
ans += pii[i].S * pii[i].F;
}
int po = n - 1;
sort(pii.begin(), pii.end());
while (m > 0) {
if (m - pii[po].S >= 0) {
ans -= pii[po].F * pii[po].S;
m -= pii[po].S;
} else {
ans -= pii[po].F * m;
break;
}
po--;
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
int main() {
ll n, m;
while (cin >> n >> m, n + m) {
ll ans = 0;
vector<pair<int, int>> pii(n);
for (int i = 0; i < n; i++) {
cin >> pii[i].S >> pii[i].F;
ans += pii[i].S * pii[i].F;
}
int po = n - 1;
sort(pii.begin(), pii.end());
while (po >= 0) {
if (m - pii[po].S >= 0) {
ans -= pii[po].F * pii[po].S;
m -= pii[po].S;
} else {
ans -= pii[po].F * m;
break;
}
po--;
}
cout << ans << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 20]]
| 1
| 239
|
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
using namespace std;
int main(void) {
long long int N, M;
while (1) {
scanf("%lld %lld", &N, &M);
if (N == 0 && M == 0)
break;
else {
vector<pair<long long int, long long int>> buri;
for (int i = 0; i < N; i++) {
long long int a, b;
scanf("%lld %lld", &a, &b);
buri.push_back(make_pair(b, a));
}
sort(buri.begin(), buri.end());
long long int ans = 0;
while (!buri.empty()) {
if (buri[N - 1].second < M) {
M -= buri[N - 1].second;
buri.pop_back();
N--;
} else {
ans += (buri[N - 1].second - M) * buri[N - 1].first;
buri.pop_back();
}
}
for (int i = 0; i < buri.size(); i++)
ans += buri[i].first * buri[i].second;
printf("%lld\n", ans);
}
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
using namespace std;
int main(void) {
long long int N, M;
while (1) {
scanf("%lld %lld", &N, &M);
if (N == 0 && M == 0)
break;
else {
vector<pair<long long int, long long int>> buri;
for (int i = 0; i < N; i++) {
long long int a, b;
scanf("%lld %lld", &a, &b);
buri.push_back(make_pair(b, a));
}
sort(buri.begin(), buri.end());
long long int ans = 0;
while (!buri.empty()) {
if (buri[N - 1].second < M) {
M -= buri[N - 1].second;
buri.pop_back();
N--;
} else {
ans += (buri[N - 1].second - M) * buri[N - 1].first;
buri.pop_back();
break;
}
}
for (int i = 0; i < buri.size(); i++)
ans += buri[i].first * buri[i].second;
printf("%lld\n", ans);
}
}
return 0;
}
|
[["+", 0, 57, 75, 76, 0, 9, 0, 93, 0, 94], ["+", 0, 57, 75, 76, 0, 9, 0, 93, 0, 35]]
| 1
| 273
|
#include <bits/stdc++.h>
using namespace std;
const int Ex = 11;
vector<int> v;
int main() {
while (1) { // start
int n, m;
cin >> n >> m;
if (n == 0 and m == 0)
break;
v.resize(Ex);
// input data
for (int i = 0; i < n; i++) {
int d, p;
cin >> d >> p;
v[p] += d;
}
// sub
for (int i = 10; i > 0; i--) {
if (m - v[i] >= 0) {
m -= v[i];
v[i] = 0;
} else {
v[i] -= m;
break;
}
}
// debug
// for(int i = 1; i < 11; i++) cout << "test = " << v[i] << endl;
// cluc
int ans = 0;
for (int i = 10; i > 0; i--) {
ans += i * v[i];
}
cout << ans << endl;
} // end
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int Ex = 11;
vector<int> v;
int main() {
while (1) { // start
int n, m;
cin >> n >> m;
if (n == 0 and m == 0)
break;
v.resize(Ex);
// input data
for (int i = 0; i < n; i++) {
int d, p;
cin >> d >> p;
v[p] += d;
}
// sub
for (int i = 10; i > 0; i--) {
if (m - v[i] >= 0) {
m -= v[i];
v[i] = 0;
} else {
v[i] -= m;
break;
}
}
// debug
// for(int i = 1; i < 11; i++) cout << "test = " << v[i] << endl;
// cluc
int ans = 0;
for (int i = 10; i > 0; i--) {
ans += i * v[i];
}
cout << ans << endl;
v.clear();
} // end
return 0;
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 195
|
#include <stdio.h>
int main() {
int n, m, d, p, a, i;
for (; scanf("%d%d", &n, &m), n | m; printf("%d\n", a)) {
a = 0;
int f[12] = {0};
for (i = n; i--; f[p] += d)
scanf("%d%d", &d, &p);
for (i = 10; i >= 0; i--) {
for (; f[i] & m;) {
m--, f[i]--;
}
a += f[i] * i;
}
}
}
|
#include <stdio.h>
int main() {
int n, m, d, p, a, i;
for (; scanf("%d%d", &n, &m), n | m; printf("%d\n", a)) {
a = 0;
int f[12] = {0};
for (i = n; i--; f[p] += d)
scanf("%d%d", &d, &p);
for (i = 10; i >= 0; i--) {
for (; f[i] && m;) {
m--, f[i]--;
}
a += f[i] * i;
}
}
}
|
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 67], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 98]]
| 1
| 142
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define mp make_pair
template <class T> void pv(T a, T b) {
for (T i = a; i != b; ++i)
cout << *i << " ";
cout << endl;
}
template <class T> void chmin(T &t, T f) {
if (t > f)
t = f;
}
template <class T> void chmax(T &t, T f) {
if (t < f)
t = f;
}
int in() {
int x;
scanf("%d", &x);
return x;
}
vector<pint> road;
int main() {
int n, m;
while (true) {
cin >> n >> m;
if (n == 0 && m == 0)
break;
int i;
for (i = 0; i < n; i++) {
int d, p;
cin >> d >> p;
road.push_back(mp(p, d));
}
sort(road.begin(), road.end(), greater<pint>());
int res = 0;
for (i = 0; i < n; i++) {
if (m >= road[i].second) {
m -= road[i].second;
} else if (m > 0) {
res += road[i].first * (road[i].second - m);
m = 0;
} else {
res += road[i].first * road[i].second;
}
}
cout << res << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define mp make_pair
template <class T> void pv(T a, T b) {
for (T i = a; i != b; ++i)
cout << *i << " ";
cout << endl;
}
template <class T> void chmin(T &t, T f) {
if (t > f)
t = f;
}
template <class T> void chmax(T &t, T f) {
if (t < f)
t = f;
}
int in() {
int x;
scanf("%d", &x);
return x;
}
vector<pint> road;
int main() {
int n, m;
while (true) {
road.clear();
cin >> n >> m;
if (n == 0 && m == 0)
break;
int i;
for (i = 0; i < n; i++) {
int d, p;
cin >> d >> p;
road.push_back(mp(p, d));
}
sort(road.begin(), road.end(), greater<pint>());
int res = 0;
for (i = 0; i < n; i++) {
if (m >= road[i].second) {
m -= road[i].second;
} else if (m > 0) {
res += road[i].first * (road[i].second - m);
m = 0;
} else {
res += road[i].first * road[i].second;
}
}
cout << res << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 388
|
// AOJ 2019
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
int n, m;
while (cin >> n >> m, n && m) {
vector<pair<int, int>> data;
int d, p;
int ret = 0;
for (int i = 0; i < n; i++) {
cin >> d >> p;
data.push_back(make_pair(p, d));
ret += (d * p);
}
sort(data.rbegin(), data.rend());
for (int i = 0; i < (int)data.size(); i++) {
if (m < data[i].second) {
ret -= m * data[i].first;
m = 0;
} else {
ret -= data[i].first * data[i].second;
m -= data[i].second;
}
}
cout << ret << endl;
}
}
|
// AOJ 2019
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
int n, m;
while (cin >> n >> m, n || m) {
vector<pair<int, int>> data;
int d, p;
int ret = 0;
for (int i = 0; i < n; i++) {
cin >> d >> p;
data.push_back(make_pair(p, d));
ret += (d * p);
}
sort(data.rbegin(), data.rend());
/*
for (int i = 0; i < data.size(); i++){
cout << data[i].first << " " << data[i].second <<
endl;
}
*/
for (int i = 0; i < (int)data.size(); i++) {
if (m < data[i].second) {
ret -= (m * data[i].first);
m = 0;
} else {
ret -= (data[i].first * data[i].second);
m -= data[i].second;
}
}
cout << ret << endl;
}
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106], ["+", 64, 9, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 64, 9, 0, 1, 0, 11, 12, 23, 0, 25], ["+", 0, 9, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 0, 9, 0, 1, 0, 11, 12, 23, 0, 25]]
| 1
| 200
|
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef pair<int, int> P;
int n, m;
P info[10001];
int main() {
while (cin >> n >> m, n || m) {
long long ans = 0;
for (int i = 0; i < n; i++)
cin >> info[i].second >> info[i].first;
sort(info, info + n);
for (int i = n - 1; i >= 0; i--) {
if (m >= info[i].second)
m -= info[i].second;
else if (m > 0) {
ans += (info[i].second - m) * info[i].first;
m = 0;
}
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef pair<int, int> P;
int n, m;
P info[10001];
int main() {
while (cin >> n >> m, n || m) {
long long ans = 0;
for (int i = 0; i < n; i++)
cin >> info[i].second >> info[i].first;
sort(info, info + n);
for (int i = n - 1; i >= 0; i--) {
if (m >= info[i].second)
m -= info[i].second;
else {
ans += (info[i].second - m) * info[i].first;
m = 0;
}
}
cout << ans << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 75, 76, 0, 57, 0, 121], ["-", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 57, 75, 76, 0, 57, 15, 339, 0, 25]]
| 1
| 175
|
#include <algorithm>
#include <iostream>
#include <utility>
bool greaterfirst(std::pair<int, int> i, std::pair<int, int> j) {
return (i.second > j.second);
}
int main() {
while (1) {
// 入力
int N, M;
std::cin >> N >> M;
if (N == 0 && M == 0)
return 0;
int D, P;
std::pair<int, int> DP[10000];
for (int i = 0; i < N; i++) {
std::cin >> D >> P;
DP[i] = std::make_pair(D, P);
}
// 演算
std::sort(DP, DP + N, greaterfirst);
int answer = 0;
for (int i = 0; i < N; i++) {
answer += DP[i].second * DP[i].first;
}
int remains = M;
for (int i = 0; remains > 0; i++) {
if (remains >= DP[i].first) {
answer -= DP[i].second * DP[i].first;
} else {
answer -= DP[i].second * remains;
}
remains -= DP[i].first;
}
// 出力
std::cout << answer << std::endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <utility>
bool greaterfirst(std::pair<int, int> i, std::pair<int, int> j) {
return (i.second > j.second);
}
int main() {
while (1) {
// 入力
int N, M;
std::cin >> N >> M;
if (N == 0 && M == 0)
return 0;
int D, P;
std::pair<int, int> DP[10000];
for (int i = 0; i < N; i++) {
std::cin >> D >> P;
DP[i] = std::make_pair(D, P);
}
// 演算
std::sort(DP, DP + N, greaterfirst);
int answer = 0;
for (int i = 0; i < N; i++) {
answer += DP[i].second * DP[i].first;
}
int remains = M;
for (int i = 0; remains > 0 && i < N; i++) {
if (remains >= DP[i].first) {
answer -= DP[i].second * DP[i].first;
} else {
answer -= DP[i].second * remains;
}
remains -= DP[i].first;
}
// 出力
std::cout << answer << std::endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 98], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 18], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22]]
| 1
| 275
|
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main() {
int N, M;
for (;;) {
scanf("%d%d", &N, &M);
if (N == 0 && M == 0)
break;
int d, p, len = 0;
vector<pair<int, int>> ds(N);
for (auto &pa : ds) {
scanf("%d%d", &d, &p);
pa = make_pair(p, d);
len += d;
}
sort(begin(ds), end(ds));
int ans = 0, rem = len - M;
for (auto &p : ds) {
int nd = min(p.second, rem);
ans += p.first * nd;
rem -= nd;
if (rem == 0)
break;
}
printf("%d\n", ans);
}
}
|
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main() {
int N, M;
for (;;) {
scanf("%d%d", &N, &M);
if (N == 0 && M == 0)
break;
int d, p, len = 0;
vector<pair<int, int>> ds(N);
for (auto &pa : ds) {
scanf("%d%d", &d, &p);
pa = make_pair(p, d);
len += d;
}
sort(begin(ds), end(ds));
int ans = 0, rem = max(len - M, 0);
for (auto &p : ds) {
int nd = min(p.second, rem);
ans += p.first * nd;
rem -= nd;
if (rem == 0)
break;
}
printf("%d\n", ans);
}
}
|
[["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 21], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
| 1
| 188
|
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
while (true) {
int n = s.nextInt();
if (n == 0)
break;
int trainNum = 0;
int maxNum = 0;
int[] startTrain = new int[n];
int[] endTrain = new int[n];
double[] train = new double[n * 2];
for (int i = 0; i < n; i++) {
String str = s.next();
String[] startTime = str.split(":");
int startH = Integer.parseInt(startTime[0]);
int startM = Integer.parseInt(startTime[0]);
int startS = Integer.parseInt(startTime[0]);
train[i] = startH * 3600 + startM * 60 + startS + 0.1;
str = s.next();
String[] endTime = str.split(":");
int endH = Integer.parseInt(endTime[0]);
int endM = Integer.parseInt(endTime[0]);
int endS = Integer.parseInt(endTime[0]);
train[n + i] = endH * 3600 + endM * 60 + endS;
}
// Arrays.sort(startTrain);
// Arrays.sort(endTrain);
Arrays.sort(train);
// int j=0;
// for (int i=0;i<n;i++){
// trainNum++;
// for(;j<n;){
// if(startTrain[i]<endTrain[j]) break;
// trainNum--;
// j++;
// }
// if(maxNum<trainNum) maxNum=trainNum;
// }
for (int i = 0; i < n * 2; i++) {
if (train[i] - Math.floor(train[i]) == 0.0)
trainNum--;
else
trainNum++;
if (maxNum < trainNum)
maxNum = trainNum;
}
System.out.println(maxNum);
}
}
}
|
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
while (true) {
int n = s.nextInt();
if (n == 0)
break;
int trainNum = 0;
int maxNum = 0;
int[] startTrain = new int[n];
int[] endTrain = new int[n];
double[] train = new double[n * 2];
for (int i = 0; i < n; i++) {
String str = s.next();
String[] startTime = str.split(":");
int startH = Integer.parseInt(startTime[0]);
int startM = Integer.parseInt(startTime[1]);
int startS = Integer.parseInt(startTime[2]);
train[i] = startH * 3600 + startM * 60 + startS + 0.1;
str = s.next();
String[] endTime = str.split(":");
int endH = Integer.parseInt(endTime[0]);
int endM = Integer.parseInt(endTime[1]);
int endS = Integer.parseInt(endTime[2]);
train[n + i] = endH * 3600 + endM * 60 + endS;
}
// Arrays.sort(startTrain);
// Arrays.sort(endTrain);
Arrays.sort(train);
// int j=0;
// for (int i=0;i<n;i++){
// trainNum++;
// for(;j<n;){
// if(startTrain[i]<endTrain[j]) break;
// trainNum--;
// j++;
// }
// if(maxNum<trainNum) maxNum=trainNum;
// }
for (int i = 0; i < n * 2; i++) {
if (train[i] - Math.floor(train[i]) == 0.0)
trainNum--;
else
trainNum++;
if (maxNum < trainNum)
maxNum = trainNum;
}
System.out.println(maxNum);
}
}
}
|
[["-", 49, 200, 51, 492, 3, 4, 0, 504, 71, 499], ["+", 49, 200, 51, 492, 3, 4, 0, 504, 71, 499]]
| 3
| 366
|
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
public class Main {
static PrintWriter out;
static InputReader ir;
static void solve() {
for (;;) {
int n = ir.nextInt();
if (n == 0)
return;
AL table = new AL();
int l, r;
for (int i = 0; i < n; i++) {
l = ir.nextInt() * 3600 + ir.nextInt() * 60 + ir.nextInt();
r = ir.nextInt() * 3600 + ir.nextInt() * 60 + ir.nextInt();
table.add(new int[] {l, r});
}
out.println(getMaxOverlap(table));
}
}
static class AL extends ArrayList<int[]> {}
static long getMaxOverlap(AL seg) {
int n = seg.size();
Point[] ps = new Point[2 * n];
for (int i = 0; i < n; i++) {
int[] s = seg.get(i);
ps[2 * i] = new Point(s[0], true);
ps[2 * i + 1] = new Point(s[1], false);
}
Arrays.sort(ps, new Comparator<Point>() {
public int compare(Point a, Point b) {
if (a.pos != b.pos)
return Integer.compare(a.pos, b.pos);
if (a.isLeftSide == b.isLeftSide)
return 0;
if (a.isLeftSide)
return -1;
return 1;
}
});
int cur = 0;
long ret = 0;
for (int i = 0; i < 2 * n; i++) {
cur += ps[i].isLeftSide ? 1 : -1;
ret = Math.max(ret, cur);
}
return ret;
}
static class Point {
public int pos;
public boolean isLeftSide;
public Point(int pos, boolean isLeftSide) {
this.pos = pos;
this.isLeftSide = isLeftSide;
}
}
public static void main(String[] args) throws Exception {
ir = new InputReader(System.in);
out = new PrintWriter(System.out);
solve();
out.flush();
}
static class InputReader {
private InputStream in;
private byte[] buffer = new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {
this.in = in;
this.curbuf = this.lenbuf = 0;
}
public boolean hasNextByte() {
if (curbuf >= lenbuf) {
curbuf = 0;
try {
lenbuf = in.read(buffer);
} catch (IOException e) {
throw new InputMismatchException();
}
if (lenbuf <= 0)
return false;
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[curbuf++];
else
return -1;
}
private boolean isSpaceChar(int c) {
return (!(c >= 33 && c <= 126)) || c == ':';
}
private void skip() {
while (hasNextByte() && isSpaceChar(buffer[curbuf]))
curbuf++;
}
public boolean hasNext() {
skip();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (!isSpaceChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public int nextInt() {
if (!hasNext())
throw new NoSuchElementException();
int c = readByte();
while (isSpaceChar(c))
c = readByte();
boolean minus = false;
if (c == '-') {
minus = true;
c = readByte();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res = res * 10 + c - '0';
c = readByte();
} while (!isSpaceChar(c));
return (minus) ? -res : res;
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
int c = readByte();
while (isSpaceChar(c))
c = readByte();
boolean minus = false;
if (c == '-') {
minus = true;
c = readByte();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res = res * 10 + c - '0';
c = readByte();
} while (!isSpaceChar(c));
return (minus) ? -res : res;
}
public double nextDouble() { return Double.parseDouble(next()); }
public int[] nextIntArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public long[] nextLongArray(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public char[][] nextCharMap(int n, int m) {
char[][] map = new char[n][m];
for (int i = 0; i < n; i++)
map[i] = next().toCharArray();
return map;
}
}
}
|
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
public class Main {
static PrintWriter out;
static InputReader ir;
static void solve() {
for (;;) {
int n = ir.nextInt();
if (n == 0)
return;
AL table = new AL();
int l, r;
for (int i = 0; i < n; i++) {
l = ir.nextInt() * 3600 + ir.nextInt() * 60 + ir.nextInt();
r = ir.nextInt() * 3600 + ir.nextInt() * 60 + ir.nextInt();
table.add(new int[] {l * 2, r * 2 - 1});
}
out.println(getMaxOverlap(table));
}
}
static class AL extends ArrayList<int[]> {}
static long getMaxOverlap(AL seg) {
int n = seg.size();
Point[] ps = new Point[2 * n];
for (int i = 0; i < n; i++) {
int[] s = seg.get(i);
ps[2 * i] = new Point(s[0], true);
ps[2 * i + 1] = new Point(s[1], false);
}
Arrays.sort(ps, new Comparator<Point>() {
public int compare(Point a, Point b) {
if (a.pos != b.pos)
return Integer.compare(a.pos, b.pos);
if (a.isLeftSide == b.isLeftSide)
return 0;
if (a.isLeftSide)
return -1;
return 1;
}
});
int cur = 0;
long ret = 0;
for (int i = 0; i < 2 * n; i++) {
cur += ps[i].isLeftSide ? 1 : -1;
ret = Math.max(ret, cur);
}
return ret;
}
static class Point {
public int pos;
public boolean isLeftSide;
public Point(int pos, boolean isLeftSide) {
this.pos = pos;
this.isLeftSide = isLeftSide;
}
}
public static void main(String[] args) throws Exception {
ir = new InputReader(System.in);
out = new PrintWriter(System.out);
solve();
out.flush();
}
static class InputReader {
private InputStream in;
private byte[] buffer = new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {
this.in = in;
this.curbuf = this.lenbuf = 0;
}
public boolean hasNextByte() {
if (curbuf >= lenbuf) {
curbuf = 0;
try {
lenbuf = in.read(buffer);
} catch (IOException e) {
throw new InputMismatchException();
}
if (lenbuf <= 0)
return false;
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[curbuf++];
else
return -1;
}
private boolean isSpaceChar(int c) {
return (!(c >= 33 && c <= 126)) || c == ':';
}
private void skip() {
while (hasNextByte() && isSpaceChar(buffer[curbuf]))
curbuf++;
}
public boolean hasNext() {
skip();
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (!isSpaceChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public int nextInt() {
if (!hasNext())
throw new NoSuchElementException();
int c = readByte();
while (isSpaceChar(c))
c = readByte();
boolean minus = false;
if (c == '-') {
minus = true;
c = readByte();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res = res * 10 + c - '0';
c = readByte();
} while (!isSpaceChar(c));
return (minus) ? -res : res;
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
int c = readByte();
while (isSpaceChar(c))
c = readByte();
boolean minus = false;
if (c == '-') {
minus = true;
c = readByte();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res = res * 10 + c - '0';
c = readByte();
} while (!isSpaceChar(c));
return (minus) ? -res : res;
}
public double nextDouble() { return Double.parseDouble(next()); }
public int[] nextIntArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public long[] nextLongArray(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public char[][] nextCharMap(int n, int m) {
char[][] map = new char[n][m];
for (int i = 0; i < n; i++)
map[i] = next().toCharArray();
return map;
}
}
}
|
[["+", 3, 4, 0, 227, 51, 518, 0, 16, 17, 48], ["+", 3, 4, 0, 227, 51, 518, 0, 16, 12, 499], ["+", 0, 227, 51, 518, 0, 16, 31, 16, 17, 48], ["+", 0, 227, 51, 518, 0, 16, 31, 16, 12, 499], ["+", 3, 4, 0, 227, 51, 518, 0, 16, 17, 33]]
| 3
| 1,218
|
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for (;;) {
int N = sc.nextInt();
if (N == 0)
break;
int[][] is = new int[N][2];
int[] time = new int[86400];
for (int i = 0; i < N; i++) {
String t1 = sc.next();
String t2 = sc.next();
is[i][0] = toSec(t1);
is[i][1] = toSec(t2);
}
for (int i = 0; i < N; i++) {
for (int s = is[i][0]; s <= is[i][0]; s++) {
time[s]++;
}
}
int max = 0;
for (int i = 0; i < 86400; i++) {
max = Math.max(max, time[i]);
}
System.out.println(max);
}
}
private static int toSec(String s) {
String[] parts = s.split(":");
int sec = 0;
for (int i = 0; i < 3; i++) {
sec = 60 * sec + Integer.parseInt(parts[i]);
}
return sec;
}
}
|
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for (;;) {
int N = sc.nextInt();
if (N == 0)
break;
int[][] is = new int[N][2];
int[] time = new int[86400];
for (int i = 0; i < N; i++) {
String t1 = sc.next();
String t2 = sc.next();
is[i][0] = toSec(t1);
is[i][1] = toSec(t2);
}
for (int i = 0; i < N; i++) {
for (int s = is[i][0]; s < is[i][1]; s++) {
time[s]++;
}
}
int max = 0;
for (int i = 0; i < 86400; i++) {
max = Math.max(max, time[i]);
}
System.out.println(max);
}
}
private static int toSec(String s) {
String[] parts = s.split(":");
int sec = 0;
for (int i = 0; i < 3; i++) {
sec = 60 * sec + Integer.parseInt(parts[i]);
}
return sec;
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 8, 196, 0, 7, 15, 16, 12, 504, 71, 499], ["+", 8, 196, 0, 7, 15, 16, 12, 504, 71, 499]]
| 3
| 311
|
#define _USE_MATH_DEFINES
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n) * (n))
#define rep(i, n) for (i = 0; i < n; i++)
#define rev(i, n) for (i = n - 1; i >= 0; i--)
#define sort(a, n) qsort(a, n, sizeof(TYPE), cmp)
#define sort_r(a, n) qsort(a, n, sizeof(TYPE), cmp_r);
#define chsort(s, n) qsort(s, n, sizeof(char), cmp)
#define chsort_r(s, n) qsort(s, n, sizeof(char), char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a, 0, sizeof(a))
int mod = (int)1e09 + 7;
int in(void) {
int i;
scanf("%d", &i);
return i;
}
long long llin(void) {
long long i;
scanf("%lld", &i);
return i;
}
double din(void) {
double i;
scanf("%lf", &i);
return i;
}
void chin(char s[]) { scanf("%s", s); }
void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) {
return strcmp((char *)a, (char *)b);
}
int char_cmp_r(const void *a, const void *b) {
return strcmp((char *)b, (char *)a);
}
void swap(int *a, int *b) {
int t = *a;
*a = *b;
*b = t;
}
long long gcd(long long x, long long y) { return x % y ? gcd(y, x % y) : y; }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int y[24 * 3600];
int main(void) {
int n, sh, sm, ss, th, tm, ts, i, s, t, ans;
while ((n = in())) {
MEMSET(y);
ans = 0;
rep(i, n) {
scanf("%d:%d:%d", &sh, &sm, &ss);
scanf("%d:%d:%d", &th, &tm, &ts);
s = sh * 3600 + sm * 60 + ss;
t = th * 3600 + tm * 60 + ts;
y[s]++;
y[t]--;
}
for (i = 1; i < 24 * 3600; i++)
y[i] += y[i - 1];
rep(i, 25 * 3600) ans = max(ans, y[i]);
print(ans);
}
return 0;
}
|
#define _USE_MATH_DEFINES
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n) * (n))
#define rep(i, n) for (i = 0; i < n; i++)
#define rev(i, n) for (i = n - 1; i >= 0; i--)
#define sort(a, n) qsort(a, n, sizeof(TYPE), cmp)
#define sort_r(a, n) qsort(a, n, sizeof(TYPE), cmp_r);
#define chsort(s, n) qsort(s, n, sizeof(char), cmp)
#define chsort_r(s, n) qsort(s, n, sizeof(char), char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a, 0, sizeof(a))
int mod = (int)1e09 + 7;
int in(void) {
int i;
scanf("%d", &i);
return i;
}
long long llin(void) {
long long i;
scanf("%lld", &i);
return i;
}
double din(void) {
double i;
scanf("%lf", &i);
return i;
}
void chin(char s[]) { scanf("%s", s); }
void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) {
return strcmp((char *)a, (char *)b);
}
int char_cmp_r(const void *a, const void *b) {
return strcmp((char *)b, (char *)a);
}
void swap(int *a, int *b) {
int t = *a;
*a = *b;
*b = t;
}
long long gcd(long long x, long long y) { return x % y ? gcd(y, x % y) : y; }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int y[24 * 3600];
int main(void) {
int n, sh, sm, ss, th, tm, ts, i, s, t, ans;
while ((n = in())) {
MEMSET(y);
ans = 0;
rep(i, n) {
scanf("%d:%d:%d", &sh, &sm, &ss);
scanf("%d:%d:%d", &th, &tm, &ts);
s = sh * 3600 + sm * 60 + ss;
t = th * 3600 + tm * 60 + ts;
y[s]++;
y[t]--;
}
for (i = 1; i < 24 * 3600; i++)
y[i] += y[i - 1];
rep(i, 24 * 3600) ans = max(ans, y[i]);
print(ans);
}
return 0;
}
|
[["-", 0, 11, 31, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 11, 31, 2, 3, 4, 0, 16, 31, 13]]
| 0
| 712
|
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b) {
int x, y;
x = *(int *)a;
y = *(int *)b;
return (x - y);
}
int main(void) {
int n;
int i, j;
int groupA[16192], groupB[16192];
int h, m, s, hh, mm, ss;
int ans;
int prev;
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
scanf("%d:%d:%d %d:%d:%d", &h, &m, &s, &hh, &mm, &ss);
groupA[i] = h * 3600 + m * 60 + s;
groupB[i] = hh * 3600 + m * 60 + s;
}
groupA[n] = INT_MAX;
groupB[n] = INT_MAX;
qsort(groupA, n + 1, sizeof(int), comp);
qsort(groupB, n + 1, sizeof(int), comp);
ans = i = j = 0;
prev = 0;
while (groupA[i] != INT_MAX && groupB[j] != INT_MAX) {
if (groupA[i] < groupB[j]) {
i++;
if (prev == 0) {
ans++;
} else {
prev--;
}
} else {
j++;
prev++;
}
}
printf("%d\n", ans);
}
return (0);
}
|
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b) {
int x, y;
x = *(int *)a;
y = *(int *)b;
return (x - y);
}
int main(void) {
int n;
int i, j;
int groupA[16192], groupB[16192];
int h, m, s, hh, mm, ss;
int ans;
int prev;
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
scanf("%d:%d:%d %d:%d:%d", &h, &m, &s, &hh, &mm, &ss);
groupA[i] = h * 3600 + m * 60 + s;
groupB[i] = hh * 3600 + mm * 60 + ss;
}
groupA[n] = INT_MAX;
groupB[n] = INT_MAX;
qsort(groupA, n + 1, sizeof(int), comp);
qsort(groupB, n + 1, sizeof(int), comp);
ans = i = j = 0;
prev = 0;
while (groupA[i] != INT_MAX && groupB[j] != INT_MAX) {
if (groupA[i] < groupB[j]) {
i++;
if (prev == 0) {
ans++;
} else {
prev--;
}
} else {
j++;
prev++;
}
}
printf("%d\n", ans);
}
return (0);
}
|
[["-", 0, 11, 12, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
| 0
| 326
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int in() {
string s;
cin >> s;
for (int i = 0; i < s.size(); i++)
s[i] -= '0';
int h = s[0] * 10 + s[1];
int m = s[3] * 10 + s[4];
int ret = s[6] * 10 + s[7];
ret += m * 60 + h * 60 * 60;
return ret;
}
int main() {
int n;
while (cin >> n, n) {
vector<int> imos(24 * 60 * 60 + 5);
while (n--) {
imos[in()]++;
imos[in() + 1]--;
}
for (int i = 1; i < 24 * 60 * 60 + 5; i++)
imos[i] += imos[i - 1];
int ans = 0;
for (int i = 0; i < 24 * 60 * 60 + 5; i++)
ans = max(ans, imos[i]);
cout << ans << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int in() {
string s;
cin >> s;
for (int i = 0; i < s.size(); i++)
s[i] -= '0';
int h = s[0] * 10 + s[1];
int m = s[3] * 10 + s[4];
int ret = s[6] * 10 + s[7];
ret += m * 60 + h * 60 * 60;
return ret;
}
int main() {
int n;
while (cin >> n, n) {
vector<int> imos(24 * 60 * 60 + 5);
while (n--) {
imos[in()]++;
imos[in()]--;
}
for (int i = 1; i < 24 * 60 * 60 + 5; i++)
imos[i] += imos[i - 1];
int ans = 0;
for (int i = 0; i < 24 * 60 * 60 + 5; i++)
ans = max(ans, imos[i]);
cout << ans << endl;
}
}
|
[["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 246
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)
const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;
template <typename T> void debug(vector<T> &vec) {
for (auto x : vec) {
cout << x << " ";
}
cout << endl;
return;
}
template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> int getFormer(const vector<T> &vec, T x) {
return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}
template <typename T> int getLatter(const vector<T> &vec, T x) {
return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}
void solve(int n) {
vector<int> vec(1e5);
REP(i, n) {
int sh, sm, ss, th, tm, ts;
scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &th, &tm, &ts);
int s = sh * 3600 + sm * 60 + ss, t = th * 3600 + tm * 60 + ts;
vec[s] += 1;
vec[t + 1] -= 1;
}
REP(i, 1e5 - 1) { vec[i + 1] += vec[i]; }
int ans = 0;
REP(i, 1e5) { ans = max(ans, vec[i]); }
cout << ans << endl;
return;
}
int main() {
int n;
while (cin >> n && n) {
solve(n);
}
return 0;
}
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)
const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;
template <typename T> void debug(vector<T> &vec) {
for (auto x : vec) {
cout << x << " ";
}
cout << endl;
return;
}
template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> int getFormer(const vector<T> &vec, T x) {
return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}
template <typename T> int getLatter(const vector<T> &vec, T x) {
return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}
void solve(int n) {
vector<int> vec(1e5);
REP(i, n) {
int sh, sm, ss, th, tm, ts;
scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &th, &tm, &ts);
int s = sh * 3600 + sm * 60 + ss, t = th * 3600 + tm * 60 + ts;
vec[s] += 1;
vec[t] -= 1;
}
REP(i, 1e5 - 1) { vec[i + 1] += vec[i]; }
int ans = 0;
REP(i, 1e5) { ans = max(ans, vec[i]); }
cout << ans << endl;
return;
}
int main() {
int n;
while (cin >> n && n) {
solve(n);
}
return 0;
}
|
[["-", 0, 11, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 417
|
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define ALL(s) s.begin(), s.end()
#define P pair<ll, ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout << n << endl
const int M = 100010;
const int MOD = 1000000007;
const int inf = 1000000007;
const long long INF = 1000000000000000007;
using ll = long long;
// int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int main() {
int n;
const int MAX = 10010;
while (1) {
int ans_1[MAX], ans_2[MAX], cnt = 0, ans = 0;
cin >> n;
if (n == 0)
break;
string s;
rep(i, 0, n) {
cin >> s;
ans_1[i] = (int)((s[0] - '0') * 10 + s[1] - '0') * 3600 +
(int)((s[3] - '0') * 10 + s[4] - '0') * 60 +
(int)((s[6] - '0') * 10 + s[7] - '0');
cin >> s;
ans_2[i] == (int)((s[0] - '0') * 10 + s[1] - '0') * 3600 +
(int)((s[3] - '0') * 10 + s[4] - '0') * 60 +
(int)((s[6] - '0') * 10 + s[7] - '0');
}
int a[90000] = {};
rep(i, 0, n) a[ans_1[i]]++, a[ans_2[i]]--;
rep(i, 0, 90000) if (a[i] != 0) cnt += a[i], ans = max(ans, cnt);
print(ans);
}
return 0;
}
|
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define ALL(s) s.begin(), s.end()
#define P pair<ll, ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout << n << endl
const int M = 100010;
const int MOD = 1000000007;
const int inf = 1000000007;
const long long INF = 1000000000000000007;
using ll = long long;
// int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int main() {
int n;
const int MAX = 10010;
while (1) {
int ans_1[MAX], ans_2[MAX], cnt = 0, ans = 0;
cin >> n;
if (n == 0)
break;
string s;
rep(i, 0, n) {
cin >> s;
ans_1[i] = (int)((s[0] - '0') * 10 + s[1] - '0') * 3600 +
(int)((s[3] - '0') * 10 + s[4] - '0') * 60 +
(int)((s[6] - '0') * 10 + s[7] - '0');
cin >> s;
ans_2[i] = (int)((s[0] - '0') * 10 + s[1] - '0') * 3600 +
(int)((s[3] - '0') * 10 + s[4] - '0') * 60 +
(int)((s[6] - '0') * 10 + s[7] - '0');
}
int a[90000] = {};
rep(i, 0, n) a[ans_1[i]]++, a[ans_2[i]]--;
rep(i, 0, 90000) if (a[i] != 0) cnt += a[i], ans = max(ans, cnt);
print(ans);
}
return 0;
}
|
[["-", 8, 9, 0, 9, 0, 1, 0, 16, 17, 60], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 32]]
| 1
| 408
|
#include <algorithm>
#include <iostream>
#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
#include <cmath>
//#include <string>
//#include <sstream>
#include <iomanip>
//#include <complex>
#include <stdio.h>
//小数制度 cout << fixed << setprecision(5) << tmp << endl;
using namespace std;
#define ll long long
#define vvi vector<vector<int>>
#define All(X) X.begin(), X.end()
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
int st[10001];
int en[10001];
vector<pair<int, int>> v;
int main() {
int n;
while (cin >> n, n) {
int h, m, s;
REP(i, n) {
scanf("%d:%d:%d", &h, &m, &s);
v.push_back(make_pair(h * 3600 + m * 60 + s, 1));
scanf("%d:%d:%d", &h, &m, &s);
v.push_back(make_pair(h * 3600 + m * 60 + s, -1));
}
sort(All(v));
int res, ans;
res = ans = 0;
for (int i = 0; i < v.size(); ++i) {
res += v[i].second;
ans = max(ans, res);
}
printf("%d\n", ans);
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
#include <cmath>
//#include <string>
//#include <sstream>
#include <iomanip>
//#include <complex>
#include <stdio.h>
//小数制度 cout << fixed << setprecision(5) << tmp << endl;
using namespace std;
#define ll long long
#define vvi vector<vector<int>>
#define All(X) X.begin(), X.end()
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
int st[10001];
int en[10001];
vector<pair<int, int>> v;
int main() {
int n;
while (cin >> n, n) {
int h, m, s;
v.clear();
REP(i, n) {
scanf("%d:%d:%d", &h, &m, &s);
v.push_back(make_pair(h * 3600 + m * 60 + s, 1));
scanf("%d:%d:%d", &h, &m, &s);
v.push_back(make_pair(h * 3600 + m * 60 + s, -1));
}
sort(All(v));
// for(int i = 0 ; i < v.size();++i) cout << v[i].first << ":" <<
// v[i].second << endl; event処理
int res, ans;
res = ans = 0;
for (int i = 0; i < v.size(); ++i) {
res += v[i].second;
ans = max(ans, res);
}
printf("%d\n", ans);
}
return 0;
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 252
|
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
vector<pii> train;
const int H = 60 * 60;
const int M = 60;
const int S = 1;
int unit[3] = {H, M, S};
int getTime(string s) {
string tmp;
int res = 0;
for (int i = 0; i < 3; i++) {
tmp = s.substr(3 * i, 2);
int val = unit[i] * atoi(tmp.c_str());
res += val;
}
return res;
}
void makeEvent(string start, string arrival) {
int st = getTime(start);
int at = getTime(arrival);
train.push_back(make_pair(st, 1));
train.push_back(make_pair(at, 0));
}
int main() {
int n;
while (cin >> n, n) {
for (int i = 0; i < n; i++) {
string start, arrival;
cin >> start >> arrival;
makeEvent(start, arrival);
}
int ans = 0, tmp = 0;
sort(train.begin(), train.end());
for (pii i : train) {
if (i.second == 1) {
tmp++;
} else {
tmp--;
}
ans = max(tmp, ans);
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
vector<pii> train;
const int H = 60 * 60;
const int M = 60;
const int S = 1;
int unit[3] = {H, M, S};
int getTime(string s) {
string tmp;
int res = 0;
for (int i = 0; i < 3; i++) {
tmp = s.substr(3 * i, 2);
int val = unit[i] * atoi(tmp.c_str());
res += val;
}
return res;
}
void makeEvent(string start, string arrival) {
int st = getTime(start);
int at = getTime(arrival);
train.push_back(make_pair(st, 1));
train.push_back(make_pair(at, 0));
}
int main() {
int n;
while (cin >> n, n) {
train.clear();
for (int i = 0; i < n; i++) {
string start, arrival;
cin >> start >> arrival;
makeEvent(start, arrival);
}
int ans = 0, tmp = 0;
sort(train.begin(), train.end());
for (pii i : train) {
if (i.second == 1) {
tmp++;
} else {
tmp--;
}
ans = max(tmp, ans);
}
cout << ans << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 304
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
int main() {
int n;
while (cin >> n) {
int data[100000] = {};
if (n == 0)
break;
rep(i, n) {
char ch;
int a, aa, aaa, b, bb, bbb;
cin >> a >> ch >> aa >> ch >> aaa >> b >> ch >> bb >> ch >> bbb;
data[a * 60 * 60 + aa * 60 + aaa] += 1;
data[b * 60 * 60 + bb * 60 + bbb] -= 1;
}
for (int i = 1; i < 40000; i++) {
data[i] = data[i] + data[i - 1];
}
int ans = -1;
rep(i, 40000) { ans = max(ans, data[i]); }
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
int main() {
int n;
while (cin >> n) {
int data[100000] = {};
if (n == 0)
break;
rep(i, n) {
char ch;
int a, aa, aaa, b, bb, bbb;
cin >> a >> ch >> aa >> ch >> aaa >> b >> ch >> bb >> ch >> bbb;
data[a * 60 * 60 + aa * 60 + aaa] += 1;
data[b * 60 * 60 + bb * 60 + bbb] -= 1;
}
for (int i = 1; i < 90000; i++) {
data[i] = data[i] + data[i - 1];
}
int ans = -1;
rep(i, 90000) { ans = max(ans, data[i]); }
cout << ans << endl;
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
| 1
| 268
|
#include <algorithm>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
int main() {
int n, h, m, s;
while (scanf("%d", &n), n) {
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
scanf("%d:%d:%d", &h, &m, &s);
v.push_back(make_pair(h * 3600 + m * 60 + s, 1));
scanf("%d:%d:%d", &h, &m, &s);
v.push_back(make_pair(h * 3600 + m * 60 + s, 0));
}
sort(v.begin(), v.end());
int cnt = 0, ans = 0;
for (int i = 0; i < n; i++) {
if (v[i].second == 1)
cnt++;
else
cnt--;
ans = max(ans, cnt);
}
printf("%d\n", ans);
}
}
|
#include <algorithm>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
int main() {
int n, h, m, s;
while (scanf("%d", &n), n) {
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
scanf("%d:%d:%d", &h, &m, &s);
v.push_back(make_pair(h * 3600 + m * 60 + s, 1));
scanf("%d:%d:%d", &h, &m, &s);
v.push_back(make_pair(h * 3600 + m * 60 + s, 0));
}
sort(v.begin(), v.end());
int cnt = 0, ans = 0;
for (int i = 0; i < v.size(); i++) {
if (v[i].second == 1)
cnt++;
else
cnt--;
ans = max(ans, cnt);
}
printf("%d\n", ans);
}
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 17, 131], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 119, 120], ["+", 0, 7, 15, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 7, 15, 16, 12, 2, 3, 4, 0, 25]]
| 1
| 219
|
#include <cstdlib>
#include <iostream>
using namespace std;
int Hen(char s, char t) { return ((s - '0') * 10 + (t - '0')); }
int main() {
string s, f;
int n, a, b, max, T[86401] = {};
while (1) {
cin >> n;
if (n == 0)
break;
for (int i = 0; i < n; i++) {
cin >> s >> f;
a = (Hen(s[0], s[1]) * 3600 + Hen(s[3], s[4]) * 60 + Hen(s[6], s[7]));
b = (Hen(f[0], f[1]) * 3600 + Hen(f[3], f[4]) * 60 + Hen(f[6], f[7]));
for (int j = a; j <= b; j++)
T[j]++;
}
max = 0;
for (int i = 0; i < 86401; i++) {
if (max < T[i])
max = T[i];
T[i] = 0;
}
cout << max << endl;
}
return 0;
}
|
#include <cstdlib>
#include <iostream>
using namespace std;
int Hen(char s, char t) { return ((s - '0') * 10 + (t - '0')); }
int main() {
string s, f;
int n, a, b, max, T[86401] = {};
while (1) {
cin >> n;
if (n == 0)
break;
for (int i = 0; i < n; i++) {
cin >> s >> f;
a = (Hen(s[0], s[1]) * 3600 + Hen(s[3], s[4]) * 60 + Hen(s[6], s[7]));
b = (Hen(f[0], f[1]) * 3600 + Hen(f[3], f[4]) * 60 + Hen(f[6], f[7]));
for (int j = a; j < b; j++)
T[j]++;
}
max = 0;
for (int i = 0; i < 86401; i++) {
if (max < T[i])
max = T[i];
T[i] = 0;
}
cout << max << endl;
}
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18]]
| 1
| 274
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX_N 100000
int x[MAX_N];
int main() {
int n, a, b, c, d, e, maxn = 0;
;
while (true) {
for (int i = 0; i < MAX_N; i++) {
x[i] = 0;
}
cin >> n;
maxn = 0;
if (n == 0) {
break;
}
for (int i = 0; i < n; i++) {
scanf("%02d:%02d:%02d", a, b, c);
d = a * 3600 + b * 60 + c;
scanf("%02d:%02d:%02d", a, b, c);
e = a * 3600 + b * 60 + c;
x[d]++;
x[e]--;
}
for (int i = 1; i < 99999; i++) {
x[i] += x[i - 1];
maxn = max(maxn, x[i]);
}
cout << maxn << endl;
}
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX_N 100000
int x[MAX_N];
int main() {
int n, a, b, c, d, e, maxn = 0;
;
while (true) {
for (int i = 0; i < MAX_N; i++) {
x[i] = 0;
}
cin >> n;
maxn = 0;
if (n == 0) {
break;
}
for (int i = 0; i < n; i++) {
scanf("%02d:%02d:%02d", &a, &b, &c);
d = a * 3600 + b * 60 + c;
scanf("%02d:%02d:%02d", &a, &b, &c);
e = a * 3600 + b * 60 + c;
x[d]++;
x[e]--;
}
for (int i = 1; i < 99999; i++) {
x[i] += x[i - 1];
maxn = max(maxn, x[i]);
}
cout << maxn << endl;
}
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
| 1
| 214
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, h, m, s, time, ans, cnt;
char q;
vector<pair<int, int>> ti;
while (1) {
cin >> n;
ans = 0, cnt = 0;
if (n == 0)
break;
for (int i = 0; i < n; i++) {
cin >> h >> q >> m >> q >> s;
time = h * 3600 + m * 60 + s;
ti.push_back(make_pair(time, 1));
cin >> h >> q >> m >> q >> s;
time = h * 3600 + m * 60 + s;
ti.push_back(make_pair(time, -1));
}
sort(ti.begin(), ti.end());
for (int i = 0; i < ti.size(); i++)
cnt += ti[i].second, ans = max(cnt, ans);
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, h, m, s, time, ans, cnt;
char q;
vector<pair<int, int>> ti;
while (1) {
cin >> n;
ans = 0, cnt = 0;
if (n == 0)
break;
for (int i = 0; i < n; i++) {
cin >> h >> q >> m >> q >> s;
time = h * 3600 + m * 60 + s;
ti.push_back(make_pair(time, 1));
cin >> h >> q >> m >> q >> s;
time = h * 3600 + m * 60 + s;
ti.push_back(make_pair(time, -1));
}
sort(ti.begin(), ti.end());
for (int i = 0; i < ti.size(); i++)
cnt += ti[i].second, ans = max(cnt, ans);
cout << ans << endl;
ti.clear();
}
return 0;
}
|
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 219
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
void slove(int n) {
vector<int> v(86400);
rep(i, 86400) v[i] = 0; //?????????
rep(i, n) {
string s, e;
cin >> s >> e;
//?§???°?????????
int start = 36000 * (s[0] - '0') + 3600 * (s[1] - '0') +
600 * (s[3] - '0') + 60 * (s[4] - '0') + 10 * (s[6] - '0') +
1 * (s[7] - '0');
int end = 36000 * (e[0] - '0') + 3600 * (e[1] - '0') + 600 * (e[3] - '0') +
60 * (e[4] - '0') + 10 * (e[6] - '0') + 1 * (e[7] - '0');
// printf("%d %d\n", start, end);
for (int j = start; j < end; ++j)
v[j]++; //???????????????
}
int ans = 0;
rep(i, 86400) { ans = max(ans, v[i]); }
// sort(all(v));
// reverse(all(v));
printf("%d\n", v[0]);
return;
}
int main(void) {
rep(i, 100000000) {
int n;
scanf("%d", &n);
if (n == 0)
break;
slove(n);
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
void slove(int n) {
vector<int> v(86400);
rep(i, 86400) v[i] = 0; //?????????
rep(i, n) {
string s, e;
cin >> s >> e;
//?§???°?????????
int start = 36000 * (s[0] - '0') + 3600 * (s[1] - '0') +
600 * (s[3] - '0') + 60 * (s[4] - '0') + 10 * (s[6] - '0') +
1 * (s[7] - '0');
int end = 36000 * (e[0] - '0') + 3600 * (e[1] - '0') + 600 * (e[3] - '0') +
60 * (e[4] - '0') + 10 * (e[6] - '0') + 1 * (e[7] - '0');
// printf("%d %d\n", start, end);
for (int j = start; j < end; ++j)
v[j]++; //???????????????
}
int ans = 0;
rep(i, 86400) { ans = max(ans, v[i]); }
// sort(all(v));
// reverse(all(v));
printf("%d\n", ans);
return;
}
int main(void) {
rep(i, 100000000) {
int n;
scanf("%d", &n);
if (n == 0)
break;
slove(n);
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
| 1
| 406
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int n;
int imos[86400];
void solve() {
rep(i, n) {
int s[3];
int t[3];
scanf("%d:%d:%d", &s[0], &s[1], &s[2]);
scanf("%d:%d:%d", &t[0], &t[1], &t[2]);
// hh:mm:ss を 秒に変換
int S = s[2] + 60 * (s[1] + s[0] * 60);
int T = t[2] + 60 * (t[1] + t[0] * 60);
// 入る時間に +1
imos[S]++;
// 出る時間+1に -1
imos[T + 1]--;
// ナイーブな実装 (写経しなくて良い)
// for(int j = S; j <= T; j++) imos[j]++;
}
// 累積和を計算する
rep(i, 86400) if (i) imos[i] += imos[i - 1];
int ans = 0;
rep(i, 86400) ans = max(ans, imos[i]);
cout << ans << endl;
}
int main() {
// こう書くとn==0のときにwhileループが停止する
while (cin >> n, n) {
rep(i, 86400) imos[i] = 0;
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int n;
int imos[86400];
void solve() {
rep(i, n) {
int s[3];
int t[3];
scanf("%d:%d:%d", &s[0], &s[1], &s[2]);
scanf("%d:%d:%d", &t[0], &t[1], &t[2]);
// hh:mm:ss を 秒に変換
int S = s[2] + 60 * (s[1] + s[0] * 60);
int T = t[2] + 60 * (t[1] + t[0] * 60);
// 入る時間に +1
imos[S]++;
// 出る時間に -1
imos[T]--;
// ナイーブな実装 (写経しなくて良い)
// for(int j = S; j <= T; j++) imos[j]++;
}
// 累積和を計算する
rep(i, 86400) if (i) imos[i] += imos[i - 1];
int ans = 0;
rep(i, 86400) ans = max(ans, imos[i]);
cout << ans << endl;
}
int main() {
// こう書くとn==0のときにwhileループが停止する
while (cin >> n, n) {
rep(i, 86400) imos[i] = 0;
solve();
}
}
|
[["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 253
|
#include <cstdio>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int n;
int add[24 * 60 * 60 + 10];
void solve() {
rep(i, 24 * 60 * 60 + 5) add[i] = 0;
rep(i, n) {
int s1, s2, s3;
int t1, t2, t3;
scanf("%d:%d:%d", &s1, &s2, &s3);
scanf("%d:%d:%d", &t1, &t2, &t3);
add[s1 * 24 * 60 + s2 * 60 + s3] = 1;
add[t1 * 24 * 60 + t2 * 60 + t3 - 1] = -1;
}
rep(i, 24 * 60 * 60 + 5) { add[i + 1] += add[i]; }
int ans = 0;
rep(i, 24 * 60 * 60 + 5) { ans = max(ans, add[i]); }
cout << ans << endl;
}
int main() {
while (cin >> n) {
if (!n)
return 0;
solve();
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int n;
int add[24 * 60 * 60 + 10];
void solve() {
rep(i, 24 * 60 * 60 + 5) add[i] = 0;
rep(i, n) {
int s1, s2, s3;
int t1, t2, t3;
scanf("%d:%d:%d", &s1, &s2, &s3);
scanf("%d:%d:%d", &t1, &t2, &t3);
add[s1 * 60 * 60 + s2 * 60 + s3] += 1;
add[t1 * 60 * 60 + t2 * 60 + t3] += -1;
}
rep(i, 24 * 60 * 60 + 5) { add[i + 1] += add[i]; }
int ans = 0;
rep(i, 24 * 60 * 60 + 5) { ans = max(ans, add[i]); }
cout << ans << endl;
}
int main() {
while (cin >> n) {
if (!n)
return 0;
solve();
}
return 0;
}
|
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 240
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = (0); (i) < (int)(n); ++(i))
using ll = long long;
int main() {
int n;
while (cin >> n, n) {
int hws[24][60][60];
rep(i, 24) rep(j, 60) rep(k, 60) hws[i][j][k] = 0;
rep(i, n) {
string s, e;
cin >> s >> e;
int h1 = stoi(s.substr(0, 2));
int m1 = stoi(s.substr(3, 2));
int s1 = stoi(s.substr(6, 2));
int h2 = stoi(e.substr(0, 2));
int m2 = stoi(e.substr(3, 2));
int s2 = stoi(e.substr(6, 2));
hws[h1][m1][s1] += 1;
hws[h2][m1][s1] -= 1;
}
int t = 0, ans = 0;
rep(i, 24) rep(j, 60) rep(k, 60) {
t += hws[i][j][k];
ans = max(t, ans);
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = (0); (i) < (int)(n); ++(i))
using ll = long long;
int main() {
int n;
while (cin >> n, n) {
int hws[24][60][60];
rep(i, 24) rep(j, 60) rep(k, 60) hws[i][j][k] = 0;
rep(i, n) {
string s, e;
cin >> s >> e;
int h1 = stoi(s.substr(0, 2));
int m1 = stoi(s.substr(3, 2));
int s1 = stoi(s.substr(6, 2));
int h2 = stoi(e.substr(0, 2));
int m2 = stoi(e.substr(3, 2));
int s2 = stoi(e.substr(6, 2));
hws[h1][m1][s1] += 1;
hws[h2][m2][s2] -= 1;
}
int t = 0, ans = 0;
rep(i, 24) rep(j, 60) rep(k, 60) {
t += hws[i][j][k];
ans = max(t, ans);
}
cout << ans << endl;
}
}
|
[["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
| 1
| 279
|
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000 // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979
using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;
int main(void) {
while (1) {
int n;
int maxi = -1;
int dp[86402] = {};
int h, m, s;
char c, d;
cin >> n;
if (n == 0) {
break;
}
FOR(i, 1, n) {
scanf("%2d%c%2d%c%2d", &h, &c, &m, &d, &s);
dp[h * 3600 + m * 60 + s]++;
scanf("%2d%c%2d%c%2d", &h, &c, &m, &d, &s);
dp[h * 3600 + m * 60 + s + 1]--;
}
FOR(i, 1, 86401) { dp[i] += dp[i - 1]; }
FOR(i, 1, 86401) {
if (dp[i] > maxi) {
maxi = dp[i];
}
}
cout << maxi << endl;
}
return 0;
}
|
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000 // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979
using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;
int main(void) {
while (1) {
int n;
int maxi = -1;
int dp[86402] = {};
int h, m, s;
char c, d;
cin >> n;
if (n == 0) {
break;
}
FOR(i, 1, n) {
scanf("%2d%c%2d%c%2d", &h, &c, &m, &d, &s);
dp[h * 3600 + m * 60 + s]++;
scanf("%2d%c%2d%c%2d", &h, &c, &m, &d, &s);
dp[h * 3600 + m * 60 + s]--;
}
FOR(i, 1, 86401) { dp[i] += dp[i - 1]; }
FOR(i, 1, 86401) {
if (dp[i] > maxi) {
maxi = dp[i];
}
}
cout << maxi << endl;
}
return 0;
}
|
[["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 288
|
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define mod 1000000007 // 1e9+7(prime number)
#define INF 1000000000 // 1e9
#define SIZE 86400 // 60*60*24
using namespace std;
typedef long long ll;
int main() {
while (1) {
int n, data[SIZE], h, m, s, t, ans;
cin >> n;
if (n == 0)
break;
REP(i, SIZE) data[i] = 0;
ans = 0;
REP(i, n) {
scanf("%d:%d:%d", &h, &m, &s);
t = h * 60 * 60 + m * 60 + s;
data[t]++;
scanf("%d:%d:%d", &h, &m, &t);
t = h * 60 * 60 + m * 60 + s;
data[t]--;
}
for (int i = 1; i < SIZE; i++)
data[i] += data[i - 1];
REP(i, SIZE) if (ans < data[i]) ans = data[i];
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define mod 1000000007 // 1e9+7(prime number)
#define INF 1000000000 // 1e9
#define SIZE 86400 // 60*60*24
using namespace std;
typedef long long ll;
int main() {
while (1) {
int n, data[SIZE], h, m, s, t, ans;
cin >> n;
if (n == 0)
break;
REP(i, SIZE) data[i] = 0;
ans = 0;
REP(i, n) {
// debug(i);
scanf("%d:%d:%d", &h, &m, &s);
t = h * 60 * 60 + m * 60 + s;
// debug(t);
data[t]++;
scanf("%d:%d:%d", &h, &m, &s);
t = h * 60 * 60 + m * 60 + s;
// debug(t);
data[t]--;
}
for (int i = 1; i < SIZE; i++)
data[i] += data[i - 1];
REP(i, SIZE) {
if (ans < data[i]) {
ans = data[i];
}
}
cout << ans << endl;
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 0, 52, 8, 9, 0, 14, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 52, 8, 9, 0, 14, 8, 9, 0, 46]]
| 1
| 237
|
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int N;
string In[10000], Out[10000];
int main() {
while (cin >> N && N > 0) {
for (int i = 0; i < N; ++i) {
cin >> Out[i] >> In[i];
sort(In, In + N);
sort(Out, Out + N);
// for (int i=0; i<N; ++i)
// cout << Out[i] << ' ' << In[i] << endl;
}
int p = 0, taiki = 0, train = 0;
for (int i = 0; i < N; ++i) {
while (p < N && In[p] <= Out[i]) {
taiki++;
p = p + 1;
}
if (taiki > 0)
taiki = taiki - 1;
else
train = train + 1;
}
cout << train << endl;
}
}
|
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int N;
string In[10000], Out[10000];
int main() {
while (cin >> N && N > 0) {
for (int i = 0; i < N; ++i) {
cin >> Out[i] >> In[i];
// for (int i=0; i<N; ++i)
// cout << Out[i] << ' ' << In[i] << endl;
}
sort(In, In + N);
sort(Out, Out + N);
int p = 0, taiki = 0, train = 0;
for (int i = 0; i < N; ++i) {
while (p < N && In[p] <= Out[i]) {
taiki++;
p = p + 1;
}
if (taiki > 0)
taiki = taiki - 1;
else
train = train + 1;
}
cout << train << endl;
}
}
|
[["+", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46]]
| 1
| 171
|
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
#define all(n) n.begin(), n.end()
const int H = 60 * 60, M = 60, CHAKU = 0, HATU = 1;
typedef pair<int, int> pp;
int main() {
int n;
while (cin >> n && n) {
int ans = 0, h, m, s;
char t;
vector<pp> tr;
REP(n) {
cin >> h >> t >> m >> t >> s;
tr.push_back(pp(h * H + m * M + s, HATU));
cin >> h >> t >> m >> t >> s;
tr.push_back(pp(h * H + m * M + s, CHAKU));
}
sort(all(tr));
int num = 0;
REP(n)
if (tr[i].second == CHAKU) {
num--;
ans = max(ans, num);
} else {
num++;
ans = max(ans, num);
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
#define all(n) n.begin(), n.end()
const int H = 60 * 60, M = 60, CHAKU = 0, HATU = 1;
typedef pair<int, int> pp;
int main() {
int n;
while (cin >> n && n) {
int ans = 0, h, m, s;
char t;
vector<pp> tr;
REP(n) {
cin >> h >> t >> m >> t >> s;
tr.push_back(pp(h * H + m * M + s, HATU));
cin >> h >> t >> m >> t >> s;
tr.push_back(pp(h * H + m * M + s, CHAKU));
}
sort(all(tr));
int num = 0;
REP(n * 2)
if (tr[i].second == CHAKU) {
num--;
ans = max(ans, num);
} else {
num++;
ans = max(ans, num);
}
cout << ans << endl;
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 241
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.