Submission #66766447


Source Code Expand

#include <bits/stdc++.h>
#define _F(x,y,z) for(int x=y;x<=z;x++)
#define F_(x,y,z) for(int x=y;x>=z;x--)
#define TF(x,y,z) for(int x=head[y],z;x;x=nex[x])

using namespace std;

typedef long long ll;
typedef const int ci;
typedef double dou;
typedef pair<int,int> pii;

ci maxn=2e6+10,p=1e9+7;

int n,h,m,dp[3010][3010];
void work()
{
    memset(dp,-1,sizeof dp);
    scanf("%d%d%d",&n,&h,&m);
    dp[0][m]=h;
    _F(i,1,n)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        _F(j,0,m)
            dp[i][j]=max(dp[i-1][j]-x,dp[i][j]);
        _F(j,y,m)
            dp[i][j-y]=max(dp[i-1][j],dp[i][j-y]);
    }
    F_(i,n,1)
    {
        int v=0;
        _F(j,0,h)
            if(dp[i][j]>=0)
                v=1;
        if(v)
        {
            printf("%d\n",i);
            return ;
        }
    }
    puts("0");

}
int main()
{
//    int t;
//    scanf("%d",&t);
//    while(t--)
        work();
    return 0;
}

Submission Info

Submission Time
Task E - Battles in a Row
User adolphshi
Language C++ 20 (gcc 12.2)
Score 450
Code Size 980 Byte
Status AC
Exec Time 30 ms
Memory 39336 KiB

Compile Error

Main.cpp: In function ‘void work()’:
Main.cpp:19:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |     scanf("%d%d%d",&n,&h,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~

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 27 ms 39196 KiB
random_02.txt AC 27 ms 39188 KiB
random_03.txt AC 19 ms 39264 KiB
random_04.txt AC 19 ms 39264 KiB
random_05.txt AC 23 ms 39200 KiB
random_06.txt AC 20 ms 39204 KiB
random_07.txt AC 28 ms 39304 KiB
random_08.txt AC 28 ms 39232 KiB
random_09.txt AC 24 ms 39092 KiB
random_10.txt AC 24 ms 39108 KiB
random_11.txt AC 27 ms 39096 KiB
random_12.txt AC 22 ms 39092 KiB
random_13.txt AC 18 ms 39204 KiB
random_14.txt AC 20 ms 39064 KiB
random_15.txt AC 23 ms 38984 KiB
random_16.txt AC 27 ms 39156 KiB
random_17.txt AC 18 ms 39304 KiB
random_18.txt AC 19 ms 39092 KiB
random_19.txt AC 27 ms 39328 KiB
random_20.txt AC 25 ms 39184 KiB
random_21.txt AC 23 ms 39204 KiB
random_22.txt AC 29 ms 39204 KiB
random_23.txt AC 21 ms 39088 KiB
random_24.txt AC 29 ms 39100 KiB
random_25.txt AC 17 ms 39264 KiB
random_26.txt AC 17 ms 39104 KiB
random_27.txt AC 17 ms 39100 KiB
random_28.txt AC 18 ms 39132 KiB
random_29.txt AC 17 ms 38984 KiB
random_30.txt AC 17 ms 39204 KiB
random_31.txt AC 23 ms 39208 KiB
random_32.txt AC 30 ms 39204 KiB
random_33.txt AC 29 ms 39092 KiB
random_34.txt AC 29 ms 39100 KiB
random_35.txt AC 30 ms 39336 KiB
random_36.txt AC 29 ms 39192 KiB
random_37.txt AC 29 ms 39332 KiB
sample_01.txt AC 16 ms 39336 KiB
sample_02.txt AC 17 ms 39096 KiB
sample_03.txt AC 18 ms 39064 KiB