Submission #1948061
Source Code Expand
#include <stdio.h>
#include <stdlib.h>
/* ソート関数 */
int int_sort( const void * a , const void * b ) {
/* 引数はvoid*型と規定されているのでint型にcastする */
if( *( int * )a < *( int * )b ) {
return 1;
}
else
if( *( int * )a == *( int * )b ) {
return 0;
}
return -1;
}
int main(void){
int N,H;
scanf("%d %d",&N,&H);
int a[N],b[N];
int maxa=0;
for(int i=0;i<N;i++){
scanf("%d %d",&a[i],&b[i]);
if(maxa<a[i])maxa=a[i];
}
qsort(( void * )b , N , sizeof( b[0] ), int_sort );
int ans=0;
for(int i=0;i<N;i++){
if(maxa>b[i])break;
H-=b[i];
ans++;
if(H<=0){
printf("%d",ans);
return 0;
}
}
ans+=(H+maxa-1)/maxa;
printf("%d",ans);
return 0;
}
Submission Info
Submission Time
2018-01-07 21:10:17+0900
Task
D - Katana Thrower
User
xxkiritoxx
Language
C (GCC 5.4.1)
Score
400
Code Size
862 Byte
Status
AC
Exec Time
30 ms
Memory
1276 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:21:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&N,&H);
^
./Main.c:25:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&a[i],&b[i]);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
400 / 400
Status
Set Name
Test Cases
Sample
a01, a02, a03, a04
All
a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name
Status
Exec Time
Memory
a01
AC
1 ms
128 KB
a02
AC
1 ms
128 KB
a03
AC
1 ms
128 KB
a04
AC
1 ms
128 KB
b05
AC
1 ms
128 KB
b06
AC
27 ms
1148 KB
b07
AC
1 ms
128 KB
b08
AC
27 ms
1148 KB
b09
AC
1 ms
128 KB
b10
AC
1 ms
128 KB
b11
AC
1 ms
128 KB
b12
AC
1 ms
128 KB
b13
AC
18 ms
1148 KB
b14
AC
18 ms
1148 KB
b15
AC
18 ms
1148 KB
b16
AC
18 ms
1148 KB
b17
AC
30 ms
1276 KB
b18
AC
27 ms
1276 KB
b19
AC
24 ms
1276 KB
b20
AC
26 ms
1276 KB
b21
AC
29 ms
1276 KB
b22
AC
28 ms
1276 KB
b23
AC
1 ms
128 KB
b24
AC
1 ms
252 KB