Submission #1951070


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <stdio.h>

struct Katana {
	int damage;
	bool isSingle;
};

int main() {
	int N, H;
	scanf("%d %d", &N, &H);
	Katana a[20000];
	for (int i = 0; i < N; ++i) {
		scanf("%d %d", &a[2 * i].damage, &a[2 * i + 1].damage);
		a[2 * i].isSingle = false;
		a[2 * i + 1].isSingle = true;
	}
	std::sort(a, a + 2 * N, [](const Katana &a, const Katana &b) {
		return a.damage > b.damage;
	});
	int ans = 0;
	int i = 0;
	while (H > 0) {
		if (a[i].isSingle) {
			H -= a[i++].damage;
			++ans;
		}
		else {
			int t = H / a[i].damage;
			ans += t;
			H -= a[i].damage * t;
			if (H > 0) {
				H -= a[i].damage;
				++ans;
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Submission Info

Submission Time
Task D - Katana Thrower
User Jenya261995
Language C++14 (GCC 5.4.1)
Score 0
Code Size 752 Byte
Status RE
Exec Time 289 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:12: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:15:57: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a[2 * i].damage, &a[2 * i + 1].damage);
                                                         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 4
AC × 12
RE × 12
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 RE 289 ms 256 KB
b07 AC 1 ms 128 KB
b08 RE 100 ms 256 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 RE 101 ms 256 KB
b14 RE 99 ms 256 KB
b15 RE 100 ms 256 KB
b16 RE 100 ms 256 KB
b17 RE 105 ms 256 KB
b18 RE 100 ms 256 KB
b19 RE 99 ms 256 KB
b20 RE 100 ms 256 KB
b21 RE 100 ms 256 KB
b22 RE 100 ms 256 KB
b23 AC 1 ms 128 KB
b24 AC 1 ms 256 KB