Submission #66773443


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <numeric>
using namespace std;
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vii vector <<int>, <int>>
#define vllvector <<ll>, <ll>>
#define vb vector<bool>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, health, magic;
    cin >> n >> health >> magic;
    vi enemy_health(n), enemy_magic(n);
    rep(i, n) {
        cin >> enemy_health[i] >> enemy_magic[i];
    }

    // number, health, magic
    queue<tuple<int, int, int>> q;
    set<tuple<int, int, int>> visited;
    // queue<tuple<int, int, int>> monster;

    q.emplace(0, health, magic);
    visited.emplace(0, health, magic);
    
    int max_kill = 0;
    while(!q.empty()) {
        tuple<int, int, int> t = q.front();
        q.pop();
        int i = get<0>(t);
        int hp = get<1>(t);
        int mp = get<2>(t);

        max_kill = max(max_kill, i);

        if(i == n) {
            continue;
        }

        if (mp >= enemy_magic[i]) {
            tuple<int, int, int> next = make_tuple(i +1, hp, mp - enemy_magic[i]);
            if(visited.count(next) == 0) {
                visited.insert(next);
                q.push(next);
            }
        }
        if(hp >= enemy_health[i]) {
            tuple<int, int, int> next = make_tuple(i + 1, hp - enemy_health[i], mp);
            if(visited.count(next) == 0) {
                visited.insert(next);
                q.push(next);
            }
        }
    }

    cout << max_kill << endl;

    return 0;
}

Submission Info

Submission Time
Task E - Battles in a Row
User kar1neko
Language C++ 20 (gcc 12.2)
Score 0
Code Size 1888 Byte
Status TLE
Exec Time 2224 ms
Memory 309144 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 450
Status
AC × 3
AC × 12
TLE × 28
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 TLE 2219 ms 203208 KiB
random_02.txt TLE 2224 ms 302756 KiB
random_03.txt TLE 2224 ms 298920 KiB
random_04.txt TLE 2219 ms 205512 KiB
random_05.txt TLE 2223 ms 298944 KiB
random_06.txt TLE 2224 ms 304044 KiB
random_07.txt TLE 2222 ms 269152 KiB
random_08.txt TLE 2223 ms 291704 KiB
random_09.txt TLE 2224 ms 303536 KiB
random_10.txt TLE 2217 ms 185876 KiB
random_11.txt TLE 2223 ms 283216 KiB
random_12.txt TLE 2224 ms 304540 KiB
random_13.txt TLE 2219 ms 215668 KiB
random_14.txt TLE 2224 ms 303224 KiB
random_15.txt TLE 2224 ms 308936 KiB
random_16.txt TLE 2220 ms 241752 KiB
random_17.txt TLE 2223 ms 289748 KiB
random_18.txt TLE 2224 ms 309144 KiB
random_19.txt TLE 2220 ms 232004 KiB
random_20.txt TLE 2223 ms 297280 KiB
random_21.txt TLE 2223 ms 301728 KiB
random_22.txt TLE 2222 ms 279112 KiB
random_23.txt TLE 2224 ms 306596 KiB
random_24.txt TLE 2224 ms 303276 KiB
random_25.txt AC 2 ms 3832 KiB
random_26.txt AC 2 ms 3844 KiB
random_27.txt AC 17 ms 7700 KiB
random_28.txt AC 1 ms 3412 KiB
random_29.txt AC 1 ms 3456 KiB
random_30.txt AC 1 ms 3440 KiB
random_31.txt AC 2 ms 4040 KiB
random_32.txt AC 2 ms 3984 KiB
random_33.txt AC 1562 ms 284996 KiB
random_34.txt TLE 2223 ms 301224 KiB
random_35.txt TLE 2224 ms 302880 KiB
random_36.txt TLE 2223 ms 301128 KiB
random_37.txt TLE 2224 ms 306724 KiB
sample_01.txt AC 1 ms 3496 KiB
sample_02.txt AC 1 ms 3512 KiB
sample_03.txt AC 1 ms 3452 KiB