Submission #2236325
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
struct p{
int l;
int r;
}a[1000000];
bool cmp(p xx,p yy){
return xx.l>yy.l;
}
int main(){
int n,h;
int c=0;
scanf("%d%d",&n,&h);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[c++].l);
a[c].r=1;
scanf("%d",&a[c++].l);
}
sort(a,a+c,cmp);
int sum=0;
for(int i=0;i<c;i++)
{
if(a[i].r==1)
{
sum++;
h-=a[i].l;
if(h<=0)
{
printf("%d",sum);
return 0;
}
}
else if(a[i].r!=1)
{
if(h%a[i].l==0) sum+=h/a[i].l;
else sum+=h/a[i].l+1;
printf("%d",sum);
return 0;
}
}
}
Submission Info
Submission Time |
|
Task |
D - Katana Thrower |
User |
chengni |
Language |
C++ (GCC 5.4.1) |
Score |
400 |
Code Size |
826 Byte |
Status |
AC |
Exec Time |
35 ms |
Memory |
1792 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:17:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&h);
^
./Main.cpp:20:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[c++].l);
^
./Main.cpp:22:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[c++].l);
^
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 |
256 KB |
a02 |
AC |
1 ms |
256 KB |
a03 |
AC |
1 ms |
256 KB |
a04 |
AC |
1 ms |
256 KB |
b05 |
AC |
1 ms |
256 KB |
b06 |
AC |
31 ms |
1792 KB |
b07 |
AC |
1 ms |
256 KB |
b08 |
AC |
31 ms |
1792 KB |
b09 |
AC |
1 ms |
256 KB |
b10 |
AC |
1 ms |
256 KB |
b11 |
AC |
1 ms |
256 KB |
b12 |
AC |
1 ms |
256 KB |
b13 |
AC |
23 ms |
1792 KB |
b14 |
AC |
22 ms |
1792 KB |
b15 |
AC |
22 ms |
1792 KB |
b16 |
AC |
22 ms |
1792 KB |
b17 |
AC |
35 ms |
1792 KB |
b18 |
AC |
31 ms |
1792 KB |
b19 |
AC |
27 ms |
1792 KB |
b20 |
AC |
28 ms |
1792 KB |
b21 |
AC |
32 ms |
1792 KB |
b22 |
AC |
33 ms |
1792 KB |
b23 |
AC |
1 ms |
256 KB |
b24 |
AC |
2 ms |
256 KB |