Submission #8477473


Source Code Expand

Copy
#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

const int MOD = 1e9+7;

pair<int,int> v[3005];
int dp[3005][3005];
bool mark[3005][3005];
int n,t;

int f(int i, int j) {
	if(i == n or j <= 0) return 0;
	if(mark[i][j]) return dp[i][j];
	mark[i][j] = true;
	int ret = f(i+1, j);
	ret = max(f(i+1, j-v[i].ff) + v[i].ss, ret);

	return dp[i][j] = ret;
}

int main() {

	scanf("%d%d", &n, &t);

	for(int i = 0; i < n; i++)
		scanf("%d%d", &v[i].ff, &v[i].ss);

	sort(v, v+n);

	printf("%d\n", f(0,t));


    return 0;
}

Submission Info

Submission Time
Task E - All-you-can-eat
User pedrohlf
Language C++14 (GCC 5.4.1)
Score 500
Code Size 634 Byte
Status AC
Exec Time 250 ms
Memory 44544 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:30:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &t);
                       ^
./Main.cpp:33:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &v[i].ff, &v[i].ss);
                                    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 31
Set Name Test Cases
Sample sample_01, sample_02, sample_03, sample_04
All corner_01, corner_02, corner_03, corner_04, corner_05, corner_06, corner_07, hand_01, hand_02, max_01, max_02, max_03, max_04, max_05, max_06, max_07, max_08, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, sample_01, sample_02, sample_03, sample_04
Case Name Status Exec Time Memory
corner_01 AC 6 ms 18688 KB
corner_02 AC 5 ms 14592 KB
corner_03 AC 9 ms 14592 KB
corner_04 AC 2 ms 4736 KB
corner_05 AC 4 ms 4736 KB
corner_06 AC 3 ms 4736 KB
corner_07 AC 11 ms 18688 KB
hand_01 AC 2 ms 2304 KB
hand_02 AC 2 ms 2304 KB
max_01 AC 250 ms 44032 KB
max_02 AC 239 ms 43392 KB
max_03 AC 11 ms 43776 KB
max_04 AC 12 ms 43776 KB
max_05 AC 79 ms 44416 KB
max_06 AC 82 ms 44544 KB
max_07 AC 79 ms 44416 KB
max_08 AC 79 ms 44544 KB
random_01 AC 49 ms 39296 KB
random_02 AC 26 ms 27008 KB
random_03 AC 64 ms 18688 KB
random_04 AC 21 ms 16640 KB
random_05 AC 29 ms 9984 KB
random_06 AC 121 ms 31104 KB
random_07 AC 112 ms 33152 KB
random_08 AC 15 ms 5120 KB
random_09 AC 80 ms 20736 KB
random_10 AC 80 ms 24960 KB
sample_01 AC 1 ms 2304 KB
sample_02 AC 1 ms 2304 KB
sample_03 AC 1 ms 2304 KB
sample_04 AC 1 ms 2304 KB