Submission #8477339


Source Code Expand

Copy
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 6'009;

int a[N];
int b[N];
int f[N];
int nf[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", a + i, b + i);
  }
  for (int i = 0; i < N; ++i) {
    f[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < N; ++j) {
      nf[j] = f[j];
    }
    for (int j = 0; j < m; ++j) {
      nf[j + a[i]] = max(nf[j + a[i]], f[j] + b[i]);
    }
    for (int j = 0; j < N; ++j) {
      f[j] = nf[j];
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans = max(ans, f[i]);
  }
  printf("%d\n", ans);
}

Submission Info

Submission Time
Task E - All-you-can-eat
User fragusbot
Language C++14 (GCC 5.4.1)
Score 0
Code Size 684 Byte
Status WA
Exec Time 32 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &m);
                        ^
./Main.cpp:17:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", a + i, b + i);
                                ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 4
AC × 14
WA × 17
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 9 ms 256 KB
corner_02 AC 8 ms 256 KB
corner_03 AC 8 ms 256 KB
corner_04 AC 2 ms 256 KB
corner_05 AC 2 ms 256 KB
corner_06 AC 2 ms 256 KB
corner_07 WA 10 ms 256 KB
hand_01 AC 1 ms 256 KB
hand_02 AC 1 ms 256 KB
max_01 WA 32 ms 256 KB
max_02 WA 31 ms 256 KB
max_03 AC 32 ms 256 KB
max_04 AC 32 ms 256 KB
max_05 WA 31 ms 256 KB
max_06 WA 31 ms 256 KB
max_07 WA 31 ms 256 KB
max_08 WA 31 ms 256 KB
random_01 WA 19 ms 256 KB
random_02 WA 13 ms 256 KB
random_03 WA 12 ms 256 KB
random_04 WA 7 ms 256 KB
random_05 WA 6 ms 256 KB
random_06 WA 19 ms 256 KB
random_07 WA 20 ms 256 KB
random_08 WA 3 ms 256 KB
random_09 WA 14 ms 256 KB
random_10 WA 15 ms 256 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB
sample_04 AC 1 ms 256 KB