Submission #66727067


Source Code Expand

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
#define pb push_back
#define ff first
#define ss second
const int N=2e3+7;
const int mod=1e9+7;
const double eps=1e-9;
const double pi=    3.14159265358979323846;
using namespace std;  
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    op_set;

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,h,m;
    cin >> n >> h >> m;

    int dp[n+1][m+1];
    memset(dp,-1,sizeof(dp));

    dp[0][m]=h;

    for(int i=1;i<=n;i++)
    {
        int a,b;
        cin >> a >> b;

        for(int j=0;j<=m;j++)
        {
            if(dp[i-1][j]>=a)
                dp[i][j]=std::max(dp[i-1][j]-a,dp[i][j]);
        }

        for(int j=b;j<=m;j++)
            dp[i][j-b]=std::max(dp[i-1][j],dp[i][j-b]);
    }

    int ans=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(dp[i][j]>=0)
                ans=i;
        }
    }

    cout << ans << "\n";
}

/*
Mar Gaye Ehsaas Meray, 
Chubay Wo Ilfaaz Teray, 
Tumne Dekha Tak Na Jaty Way, 
*/

Submission Info

Submission Time
Task E - Battles in a Row
User 18o3
Language C++ 23 (gcc 12.2)
Score 450
Code Size 1277 Byte
Status AC
Exec Time 42 ms
Memory 38784 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 40
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 35 ms 25892 KiB
random_02.txt AC 35 ms 25632 KiB
random_03.txt AC 21 ms 10200 KiB
random_04.txt AC 6 ms 9972 KiB
random_05.txt AC 13 ms 18488 KiB
random_06.txt AC 7 ms 11872 KiB
random_07.txt AC 23 ms 29364 KiB
random_08.txt AC 21 ms 28292 KiB
random_09.txt AC 19 ms 25728 KiB
random_10.txt AC 13 ms 17760 KiB
random_11.txt AC 21 ms 28048 KiB
random_12.txt AC 14 ms 18460 KiB
random_13.txt AC 5 ms 6332 KiB
random_14.txt AC 15 ms 12116 KiB
random_15.txt AC 15 ms 13808 KiB
random_16.txt AC 33 ms 27268 KiB
random_17.txt AC 8 ms 8428 KiB
random_18.txt AC 11 ms 9580 KiB
random_19.txt AC 34 ms 26680 KiB
random_20.txt AC 21 ms 17952 KiB
random_21.txt AC 25 ms 20000 KiB
random_22.txt AC 42 ms 31672 KiB
random_23.txt AC 15 ms 13356 KiB
random_24.txt AC 39 ms 29224 KiB
random_25.txt AC 1 ms 3512 KiB
random_26.txt AC 1 ms 3432 KiB
random_27.txt AC 2 ms 4240 KiB
random_28.txt AC 1 ms 3524 KiB
random_29.txt AC 2 ms 3388 KiB
random_30.txt AC 1 ms 3456 KiB
random_31.txt AC 28 ms 38572 KiB
random_32.txt AC 32 ms 38576 KiB
random_33.txt AC 31 ms 38644 KiB
random_34.txt AC 31 ms 38572 KiB
random_35.txt AC 31 ms 38648 KiB
random_36.txt AC 31 ms 38568 KiB
random_37.txt AC 30 ms 38784 KiB
sample_01.txt AC 1 ms 3472 KiB
sample_02.txt AC 1 ms 3504 KiB
sample_03.txt AC 1 ms 3448 KiB