Submission #66746613
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;int main() {int N, H, M;cin >> N >> H >> M;vector<int> A(N), B(N);for (int i = 0; i < N; ++i) {cin >> A[i] >> B[i];}const int MAX = 3001;vector<vector<bool>> visited(MAX, vector<bool>(MAX, false));visited[H][M] = true;deque<pair<int, int>> cur;cur.emplace_back(H, M);int ans = 0;for (int i = 0; i < N; ++i) {deque<pair<int, int>> nxt;vector<vector<bool>> new_visited(MAX, vector<bool>(MAX, false));while (!cur.empty()) {auto [h, m] = cur.front(); cur.pop_front();
#include <bits/stdc++.h> using namespace std; int main() { int N, H, M; cin >> N >> H >> M; vector<int> A(N), B(N); for (int i = 0; i < N; ++i) { cin >> A[i] >> B[i]; } const int MAX = 3001; vector<vector<bool>> visited(MAX, vector<bool>(MAX, false)); visited[H][M] = true; deque<pair<int, int>> cur; cur.emplace_back(H, M); int ans = 0; for (int i = 0; i < N; ++i) { deque<pair<int, int>> nxt; vector<vector<bool>> new_visited(MAX, vector<bool>(MAX, false)); while (!cur.empty()) { auto [h, m] = cur.front(); cur.pop_front(); if (h >= A[i]) { int nh = h - A[i], nm = m; if (!new_visited[nh][nm]) { new_visited[nh][nm] = true; nxt.emplace_back(nh, nm); } } if (m >= B[i]) { int nh = h, nm = m - B[i]; if (!new_visited[nh][nm]) { new_visited[nh][nm] = true; nxt.emplace_back(nh, nm); } } } if (nxt.empty()) break; visited = move(new_visited); cur = move(nxt); ++ans; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Battles in a Row |
User | Untitle |
Language | C++ 23 (gcc 12.2) |
Score | 0 |
Code Size | 1314 Byte |
Status | TLE |
Exec Time | 2211 ms |
Memory | 34336 KiB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 450 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
random_01.txt | AC | 1707 ms | 21068 KiB |
random_02.txt | TLE | 2209 ms | 21524 KiB |
random_03.txt | TLE | 2208 ms | 13556 KiB |
random_04.txt | AC | 877 ms | 23676 KiB |
random_05.txt | TLE | 2208 ms | 16548 KiB |
random_06.txt | TLE | 2208 ms | 16364 KiB |
random_07.txt | TLE | 2209 ms | 22784 KiB |
random_08.txt | TLE | 2209 ms | 30148 KiB |
random_09.txt | TLE | 2208 ms | 17172 KiB |
random_10.txt | AC | 1062 ms | 27048 KiB |
random_11.txt | TLE | 2209 ms | 34336 KiB |
random_12.txt | TLE | 2208 ms | 16704 KiB |
random_13.txt | AC | 1636 ms | 23420 KiB |
random_14.txt | TLE | 2208 ms | 20940 KiB |
random_15.txt | TLE | 2208 ms | 12692 KiB |
random_16.txt | AC | 1096 ms | 19656 KiB |
random_17.txt | TLE | 2211 ms | 24476 KiB |
random_18.txt | AC | 1871 ms | 15508 KiB |
random_19.txt | AC | 1131 ms | 20852 KiB |
random_20.txt | AC | 1958 ms | 12172 KiB |
random_21.txt | TLE | 2208 ms | 16428 KiB |
random_22.txt | AC | 471 ms | 12632 KiB |
random_23.txt | TLE | 2209 ms | 20728 KiB |
random_24.txt | TLE | 2208 ms | 13348 KiB |
random_25.txt | AC | 56 ms | 6036 KiB |
random_26.txt | AC | 56 ms | 6044 KiB |
random_27.txt | AC | 91 ms | 5964 KiB |
random_28.txt | AC | 4 ms | 5612 KiB |
random_29.txt | AC | 4 ms | 5464 KiB |
random_30.txt | AC | 5 ms | 5576 KiB |
random_31.txt | AC | 1623 ms | 5724 KiB |
random_32.txt | AC | 1592 ms | 5968 KiB |
random_33.txt | AC | 1296 ms | 6208 KiB |
random_34.txt | TLE | 2208 ms | 16592 KiB |
random_35.txt | TLE | 2208 ms | 16544 KiB |
random_36.txt | TLE | 2208 ms | 17136 KiB |
random_37.txt | TLE | 2208 ms | 16648 KiB |
sample_01.txt | AC | 5 ms | 5496 KiB |
sample_02.txt | AC | 5 ms | 5588 KiB |
sample_03.txt | AC | 8 ms | 5500 KiB |