Submission #1971731


Source Code Expand

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define FOR(i,s,e) for(int i = (s);i <= (e);i++)

int N;


int A[3010];
int B[3010];

int S;
int T;

int dp[3010][3010];

int main()
{
    cin >> N >> T >> S;

    FOR(i,1,N) cin >> A[i] >> B[i];

    FOR(i,1,N)
    {
        FOR(j,0,T)
        {
            dp[i][j] = dp[i - 1][j];

            if(j > 0)
            {
                dp[i][j] = max(dp[i][j] , dp[i][j - 1]);
            }
            
            if(!(j - B[i] < S && S < j) && j - B[i] >= 0)
            {
                dp[i][j] = max(dp[i][j],dp[i - 1][j - B[i]] + A[i]);
            }
        }
    }

    cout << dp[N][T] << endl;
    return 0;
}

Submission Info

Submission Time
Task C - 夜店 (Night Market)
User niuez
Language C++14 (GCC 5.4.1)
Score 100
Code Size 818 Byte
Status AC
Exec Time 60 ms
Memory 35584 KB

Judge Result

Set Name set01 set02 set03 set04 set05 set06 set07 set08 set09 set10
Score / Max Score 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10
Status
AC × 2
AC × 2
AC × 2
AC × 2
AC × 2
AC × 2
AC × 2
AC × 2
AC × 2
AC × 2
Set Name Test Cases
set01 01-01.txt, 01-02.txt
set02 02-01.txt, 02-02.txt
set03 03-01.txt, 03-02.txt
set04 04-01.txt, 04-02.txt
set05 05-01.txt, 05-02.txt
set06 06-01.txt, 06-02.txt
set07 07-01.txt, 07-02.txt
set08 08-01.txt, 08-02.txt
set09 09-01.txt, 09-02.txt
set10 10-01.txt, 10-02.txt
Case Name Status Exec Time Memory
01-01.txt AC 2 ms 512 KB
01-02.txt AC 1 ms 512 KB
02-01.txt AC 49 ms 35584 KB
02-02.txt AC 49 ms 35584 KB
03-01.txt AC 49 ms 35584 KB
03-02.txt AC 49 ms 35584 KB
04-01.txt AC 60 ms 35584 KB
04-02.txt AC 60 ms 35584 KB
05-01.txt AC 48 ms 35584 KB
05-02.txt AC 47 ms 35584 KB
06-01.txt AC 48 ms 35584 KB
06-02.txt AC 47 ms 35584 KB
07-01.txt AC 43 ms 35584 KB
07-02.txt AC 46 ms 35584 KB
08-01.txt AC 43 ms 35584 KB
08-02.txt AC 44 ms 35584 KB
09-01.txt AC 44 ms 35584 KB
09-02.txt AC 44 ms 35584 KB
10-01.txt AC 45 ms 35584 KB
10-02.txt AC 48 ms 35584 KB