Submission #1972659


Source Code Expand

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
void solve(long long N, long long H, vector<long long> a, vector<long long> b){
	priority_queue< pair<ll,int> > Q;
	for(int i = 0 ; i < a.size() ; i++){
		Q.push({b[i], i});
	}
	long long ans = 0;
	while(H > 0){
		auto w = Q.top(); Q.pop();
		if( w.second >= 0 ){
			H -= w.first;
			ans++;
			Q.push({a[w.second], -1});
		}else{
			ans += (H+w.first-1) / w.first;
			break;
		}
	}
	cout << ans << endl;
}

int main(){	
	long long N;
	long long H;
	scanf("%lld",&N);
	vector<long long> b(N-1+1);
	vector<long long> a(N-1+1);
	scanf("%lld",&H);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
		scanf("%lld",&b[i]);
	}
	solve(N, H, a, b);
	return 0;
}

Submission Info

Submission Time
Task D - Katana Thrower
User kyuridenamida
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2200 Byte
Status AC
Exec Time 39 ms
Memory 5620 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:102:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&N);
                  ^
./Main.cpp:105:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&H);
                  ^
./Main.cpp:107:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
                      ^
./Main.cpp:108:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&b[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 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 5492 KB
b07 AC 1 ms 256 KB
b08 AC 31 ms 5620 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 30 ms 5492 KB
b14 AC 26 ms 5620 KB
b15 AC 22 ms 5492 KB
b16 AC 29 ms 5492 KB
b17 AC 23 ms 5620 KB
b18 AC 22 ms 5620 KB
b19 AC 34 ms 5492 KB
b20 AC 29 ms 5620 KB
b21 AC 37 ms 5620 KB
b22 AC 39 ms 5620 KB
b23 AC 1 ms 256 KB
b24 AC 2 ms 384 KB