Submission #456397

# Submission time Handle Problem Language Result Execution time Memory
456397 2021-08-06T16:13:37 Z ntabc05101 Go (COCI16_go) C++14
0 / 50
1 ms 460 KB
#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

#define taskname ""

int main() {
  if (fopen(taskname".inp", "r")) {
    freopen(taskname".inp", "r", stdin);
    freopen(taskname".out", "w", stdout);
  }

  cin.tie(0)->sync_with_stdio(0);

  int n, k, m; cin >> n >> k >> m;
  array<int, 3> a[m];
  for (int i = 1; i <= m; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }

  a[0] = {k, 0, 0};
  sort(a + 1, a + m + 1, [&](auto const& x, auto const& y) {
    return x[1] + x[2] < y[1] + y[2];
  });

  int dp[m + 1][2001];
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= 2000; j++) {
      dp[i][j] = -mod;
    }
  }
  dp[0][0] = 0;
  int res = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < i; j++) {
      int z = abs(a[i][0] - a[j][0]) + 1;
      for (int k = z; k <= a[i][2]; k++) {
        dp[i][k] = max(dp[i][k], dp[j][k - z] + a[i][1]);
        res = max(res, dp[i][k]);
      }
    }
  }

  cout << res << endl;

  return 0;
}

Compilation message

go.cpp: In function 'int main()':
go.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen(taskname".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
go.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen(taskname".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Runtime error 1 ms 332 KB Execution killed with signal 11
4 Runtime error 1 ms 332 KB Execution killed with signal 11
5 Runtime error 1 ms 332 KB Execution killed with signal 11
6 Runtime error 1 ms 332 KB Execution killed with signal 11
7 Runtime error 1 ms 332 KB Execution killed with signal 11
8 Runtime error 1 ms 332 KB Execution killed with signal 11
9 Runtime error 1 ms 332 KB Execution killed with signal 11
10 Runtime error 1 ms 460 KB Execution killed with signal 11
11 Runtime error 1 ms 332 KB Execution killed with signal 11
12 Runtime error 1 ms 332 KB Execution killed with signal 11
13 Runtime error 1 ms 332 KB Execution killed with signal 11
14 Runtime error 1 ms 332 KB Execution killed with signal 11
15 Runtime error 1 ms 332 KB Execution killed with signal 11
16 Runtime error 1 ms 332 KB Execution killed with signal 11
17 Runtime error 1 ms 332 KB Execution killed with signal 11
18 Runtime error 1 ms 460 KB Execution killed with signal 11
19 Runtime error 1 ms 332 KB Execution killed with signal 11
20 Runtime error 1 ms 332 KB Execution killed with signal 11
21 Runtime error 1 ms 444 KB Execution killed with signal 11
22 Runtime error 1 ms 332 KB Execution killed with signal 11
23 Runtime error 1 ms 436 KB Execution killed with signal 11
24 Runtime error 1 ms 440 KB Execution killed with signal 11
25 Runtime error 1 ms 332 KB Execution killed with signal 11