Submission #1949428
Source Code Expand
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int h;
int ans;
struct point
{
int a,b;
}p[100010];
bool cmp(point p1,point p2)
{
return p1.b>p2.b;
}
int main()
{
scanf("%d%d",&n,&h);
int maxx=0;
for(int i=1;i<=n;i++)
{
scanf("%d%d",&p[i].a,&p[i].b);
maxx=max(p[i].a,maxx);
}
sort(p+1,p+n+1,cmp);
for(int i=1;i<=n;i++)
{
if(p[i].b<maxx)
{
break;
}
h-=p[i].b;
ans++;
if(h<=0)
{
ans=i;
break;
}
}
if(h>0)
{
if(h%maxx==0)
ans+=h/maxx;
else
{
ans+=h/maxx;
ans++;
}
}
printf("%d\n",ans);
return 0;
}
Submission Info
Submission Time
2018-01-07 21:27:10+0900
Task
D - Katana Thrower
User
FTS
Language
C++14 (GCC 5.4.1)
Score
400
Code Size
622 Byte
Status
AC
Exec Time
25 ms
Memory
896 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:17:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&h);
^
./Main.cpp:21:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&p[i].a,&p[i].b);
^
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
25 ms
896 KB
b07
AC
1 ms
128 KB
b08
AC
25 ms
896 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
16 ms
896 KB
b14
AC
16 ms
896 KB
b15
AC
16 ms
896 KB
b16
AC
16 ms
896 KB
b17
AC
25 ms
896 KB
b18
AC
22 ms
896 KB
b19
AC
19 ms
896 KB
b20
AC
20 ms
896 KB
b21
AC
24 ms
896 KB
b22
AC
23 ms
896 KB
b23
AC
1 ms
128 KB
b24
AC
1 ms
128 KB