Submission #2075215


Source Code Expand

#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
int main()
{
	int num;
	ll gen;
	scanf("%d%lld", &num, &gen);
	vector<pii>v;
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		v.push_back(make_pair(zb, 1));
		v.push_back(make_pair(za, 0));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0;; i++)
	{
		if (v[i].second == 0)
		{
			printf("%lld\n", ans + (gen + v[i].first - 1) / v[i].first);
			break;
		}
		else
		{
			ans++;
			gen -= v[i].first;
			if (gen <= 0)
			{
				printf("%lld\n", ans);
				break;
			}
		}
	}
}

Submission Info

Submission Time
Task D - Katana Thrower
User DEGwer
Language C++14 (GCC 5.4.1)
Score 400
Code Size 702 Byte
Status AC
Exec Time 35 ms
Memory 6384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld", &num, &gen);
                             ^
./Main.cpp:16:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &za, &zb);
                          ^

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 30 ms 6384 KB
b07 AC 1 ms 256 KB
b08 AC 30 ms 5872 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 22 ms 6128 KB
b14 AC 22 ms 6256 KB
b15 AC 21 ms 6000 KB
b16 AC 22 ms 5616 KB
b17 AC 35 ms 5232 KB
b18 AC 32 ms 6128 KB
b19 AC 27 ms 5616 KB
b20 AC 29 ms 5616 KB
b21 AC 32 ms 5488 KB
b22 AC 33 ms 4720 KB
b23 AC 1 ms 256 KB
b24 AC 2 ms 384 KB