Submission #67746502
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;int main() {ios::sync_with_stdio(false);cin.tie(nullptr);long long n;int m;cin >> n >> m;vector<long long> a(m), b(m);for (int i = 0; i < m; i++) {cin >> a[i] >> b[i];}vector<tuple<long long, double, long long, long long>> C;for (int i = 0; i < m; i++) {double efficiency = (double)b[i] / a[i];C.emplace_back(b[i] - a[i], efficiency, a[i], b[i]);}
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n;
int m;
cin >> n >> m;
vector<long long> a(m), b(m);
for (int i = 0; i < m; i++) {
cin >> a[i] >> b[i];
}
vector<tuple<long long, double, long long, long long>> C;
for (int i = 0; i < m; i++) {
double efficiency = (double)b[i] / a[i];
C.emplace_back(b[i] - a[i], efficiency, a[i], b[i]);
}
sort(C.begin(), C.end(), [](auto &x, auto &y) {
if (get<0>(x) != get<0>(y)) return get<0>(x) > get<0>(y);
return get<1>(x) > get<1>(y);
});
long long full = n;
long long emp = 0;
long long answer = 0;
while (true) {
emp += full;
full = 0;
bool ex = false;
for (auto &[diff, eff, A, B] : C) {
if (emp >= A) {
long long times = emp / A;
emp -= times * A;
full += times * B;
answer += times;
ex = true;
break;
}
}
if (!ex) break;
}
cout << answer << "\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Get Many Stickers |
| User | practicejoi |
| Language | C++ 23 (gcc 12.2) |
| Score | 0 |
| Code Size | 1218 Byte |
| Status | TLE |
| Exec Time | 2212 ms |
| Memory | 14664 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||||
| 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_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3448 KiB |
| 00_sample_01.txt | AC | 1 ms | 3500 KiB |
| 00_sample_02.txt | AC | 1 ms | 3644 KiB |
| 01_random_00.txt | AC | 25 ms | 8904 KiB |
| 01_random_01.txt | AC | 36 ms | 13640 KiB |
| 01_random_02.txt | AC | 43 ms | 13992 KiB |
| 01_random_03.txt | AC | 40 ms | 14632 KiB |
| 01_random_04.txt | AC | 40 ms | 14560 KiB |
| 01_random_05.txt | AC | 40 ms | 14616 KiB |
| 02_random2_00.txt | TLE | 2208 ms | 14536 KiB |
| 02_random2_01.txt | TLE | 2208 ms | 14532 KiB |
| 02_random2_02.txt | TLE | 2212 ms | 14616 KiB |
| 02_random2_03.txt | AC | 46 ms | 14644 KiB |
| 02_random2_04.txt | AC | 46 ms | 14552 KiB |
| 02_random2_05.txt | AC | 46 ms | 14572 KiB |
| 02_random2_06.txt | TLE | 2208 ms | 14616 KiB |
| 02_random2_07.txt | TLE | 2208 ms | 14524 KiB |
| 02_random2_08.txt | TLE | 2208 ms | 14640 KiB |
| 02_random2_09.txt | TLE | 2208 ms | 14664 KiB |
| 02_random2_10.txt | TLE | 2208 ms | 14656 KiB |
| 02_random2_11.txt | TLE | 2208 ms | 14600 KiB |
| 03_random3_00.txt | TLE | 2208 ms | 14652 KiB |
| 03_random3_01.txt | TLE | 2208 ms | 14584 KiB |
| 03_random3_02.txt | TLE | 2208 ms | 14480 KiB |
| 03_random3_03.txt | TLE | 2208 ms | 14660 KiB |
| 03_random3_04.txt | TLE | 2208 ms | 14532 KiB |
| 04_handmade_00.txt | AC | 22 ms | 14476 KiB |
| 04_handmade_01.txt | AC | 21 ms | 14580 KiB |
| 04_handmade_02.txt | AC | 1 ms | 3504 KiB |
| 04_handmade_03.txt | AC | 1 ms | 3560 KiB |
| 04_handmade_04.txt | TLE | 2207 ms | 14652 KiB |