Submission #2551788
Source Code Expand
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define ms_valtype pair
typedef struct {
int w;
int b;
}pair;
//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
return (b.b + b.w) - (a.b + a.w);
}
//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
if(right - left > 1){
int i, j, k, half = (left + right) / 2;
sort_sub(origin, left, half, tmp);
sort_sub(origin, half, right, tmp);
for(i = left; i < right; i++){
tmp[i] = origin[i];
}
for(i = left, j = left, k = half; i < right; i++){
if(k == right){
origin[i] = tmp[j];
j++;
}
else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
origin[i] = tmp[j];
j++;
}
else{
origin[i] = tmp[k];
k++;
}
}
}
}
void sort(ms_valtype *origin, int N){
ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
sort_sub(origin, 0, N, tmp);
free(tmp);
}
signed main(){
int N, P, i, sum = 0;
scanf("%lld%lld", &N, &P);
pair *ps = (pair *)malloc(sizeof(pair) * N);
for(i = 0; i < N; i++){
scanf("%lld%lld", &ps[i].w, &ps[i].b);
ps[i].w *= (100 - P);
ps[i].b *= P;
sum -= ps[i].b;
}
sort(ps, N);
for(i = 0; i < N; i++){
sum += ps[i].w + ps[i].b;
if(sum >= 0){
printf("%lld\n", i + 1);
return 0;
}
}
}
Submission Info
Submission Time
2018-05-23 20:34:36+0900
Task
E - White and Blue
User
abc050
Language
C (GCC 5.4.1)
Score
100
Code Size
1352 Byte
Status
AC
Exec Time
32 ms
Memory
3328 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:50:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld", &N, &P);
^
./Main.c:53:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld", &ps[i].w, &ps[i].b);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
100 / 100
Status
Set Name
Test Cases
Sample
a01, a02, a03
All
a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23
Case Name
Status
Exec Time
Memory
a01
AC
1 ms
128 KB
a02
AC
1 ms
128 KB
a03
AC
1 ms
128 KB
b04
AC
1 ms
128 KB
b05
AC
29 ms
3328 KB
b06
AC
29 ms
3328 KB
b07
AC
28 ms
3328 KB
b08
AC
28 ms
3328 KB
b09
AC
28 ms
3328 KB
b10
AC
27 ms
3328 KB
b11
AC
27 ms
3328 KB
b12
AC
20 ms
3328 KB
b13
AC
25 ms
3328 KB
b14
AC
25 ms
3328 KB
b15
AC
28 ms
3200 KB
b16
AC
25 ms
3328 KB
b17
AC
27 ms
3328 KB
b18
AC
25 ms
3328 KB
b19
AC
27 ms
3328 KB
b20
AC
28 ms
3328 KB
b21
AC
28 ms
3328 KB
b22
AC
32 ms
3328 KB
b23
AC
28 ms
3328 KB