Submission #43360062
Source Code Expand
import std;
void read(T...)(string S, ref T args) {
auto buf = S.split;
foreach (i, ref arg; args) {
arg = buf[i].to!(typeof(arg));
}
}
struct pair {
int a;
int b;
}
void main () {
int N, K; readln.read(N, K);
pair[] medicine = new pair[](N);
foreach (i; 0..N) {
readln.read(medicine[i].a, medicine[i].b);
}
solve(N, K, medicine);
}
void solve (int N, int K, pair[] medicine) {
medicine.sort!((x, y) => x.a < y.a);
import std.algorithm : reduce;
long medicineSum = reduce!((x, y) => x + y.b)(0L, medicine);
// 初日チェック
if (medicineSum <= K) {
writeln(1);
return;
}
foreach (i; 0..N) {
medicineSum -= medicine[i].b;
if (medicineSum <= K) {
writeln(medicine[i].a+1);
break;
}
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Medicine |
| User | InTheBloom |
| Language | D (DMD 2.091.0) |
| Score | 350 |
| Code Size | 890 Byte |
| Status | AC |
| Exec Time | 218 ms |
| Memory | 14204 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 350 / 350 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_srnd_00.txt, 01_srnd_01.txt, 01_srnd_02.txt, 01_srnd_03.txt, 01_srnd_04.txt, 01_srnd_05.txt, 02_rnd_00.txt, 02_rnd_01.txt, 02_rnd_02.txt, 02_rnd_03.txt, 02_rnd_04.txt, 02_rnd_05.txt, 03_minmax_00.txt, 03_minmax_01.txt, 03_minmax_02.txt, 03_minmax_03.txt, 03_minmax_04.txt, 03_minmax_05.txt, 03_minmax_06.txt, 03_minmax_07.txt, 04_hand_00.txt, 04_hand_01.txt, 04_hand_02.txt, 04_hand_03.txt, 04_hand_04.txt, 04_hand_05.txt, 04_hand_06.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 8 ms | 3552 KiB |
| 00_sample_01.txt | AC | 2 ms | 3612 KiB |
| 00_sample_02.txt | AC | 2 ms | 3468 KiB |
| 01_srnd_00.txt | AC | 2 ms | 3576 KiB |
| 01_srnd_01.txt | AC | 2 ms | 3524 KiB |
| 01_srnd_02.txt | AC | 2 ms | 3584 KiB |
| 01_srnd_03.txt | AC | 2 ms | 3552 KiB |
| 01_srnd_04.txt | AC | 2 ms | 3604 KiB |
| 01_srnd_05.txt | AC | 2 ms | 3640 KiB |
| 02_rnd_00.txt | AC | 218 ms | 6736 KiB |
| 02_rnd_01.txt | AC | 216 ms | 14128 KiB |
| 02_rnd_02.txt | AC | 210 ms | 6808 KiB |
| 02_rnd_03.txt | AC | 185 ms | 6824 KiB |
| 02_rnd_04.txt | AC | 189 ms | 6732 KiB |
| 02_rnd_05.txt | AC | 186 ms | 6680 KiB |
| 03_minmax_00.txt | AC | 128 ms | 6816 KiB |
| 03_minmax_01.txt | AC | 159 ms | 6804 KiB |
| 03_minmax_02.txt | AC | 165 ms | 14176 KiB |
| 03_minmax_03.txt | AC | 197 ms | 14204 KiB |
| 03_minmax_04.txt | AC | 129 ms | 6816 KiB |
| 03_minmax_05.txt | AC | 158 ms | 6900 KiB |
| 03_minmax_06.txt | AC | 160 ms | 6780 KiB |
| 03_minmax_07.txt | AC | 187 ms | 6844 KiB |
| 04_hand_00.txt | AC | 2 ms | 3592 KiB |
| 04_hand_01.txt | AC | 3 ms | 3552 KiB |
| 04_hand_02.txt | AC | 183 ms | 6716 KiB |
| 04_hand_03.txt | AC | 185 ms | 6860 KiB |
| 04_hand_04.txt | AC | 183 ms | 6840 KiB |
| 04_hand_05.txt | AC | 187 ms | 6804 KiB |
| 04_hand_06.txt | AC | 188 ms | 6872 KiB |