Submission #1963134


Source Code Expand

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int q[110000];

int main(){
	int a;
	long long b;scanf("%d%lld",&a,&b);
	int ma=0;
	for(int i=0;i<a;i++){
		scanf("%d%d",p+i,q+i);
		ma=max(ma,p[i]);
	}
	int ret=mod;
	int tmp=0;
	std::sort(q,q+a);
	for(int i=a;i>=0;i--){
		if(i){
			b-=q[i-1];
			tmp++;
		}
		int cost=0;
		if(b>0){
			cost=(b+ma-1)/ma;
		}
		ret=min(ret,tmp+cost);
	}
	printf("%d\n",ret);
}

Submission Info

Submission Time
Task D - Katana Thrower
User tozangezan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 904 Byte
Status AC
Exec Time 23 ms
Memory 896 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  long long b;scanf("%d%lld",&a,&b);
                                   ^
./Main.cpp:31:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",p+i,q+i);
                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 24
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 23 ms 896 KB
b07 AC 1 ms 128 KB
b08 AC 23 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 15 ms 896 KB
b15 AC 14 ms 896 KB
b16 AC 16 ms 896 KB
b17 AC 22 ms 896 KB
b18 AC 21 ms 896 KB
b19 AC 17 ms 896 KB
b20 AC 19 ms 896 KB
b21 AC 22 ms 896 KB
b22 AC 21 ms 896 KB
b23 AC 1 ms 128 KB
b24 AC 1 ms 128 KB