답안 #932935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932935 2024-02-24T15:04:22 Z stefanneagu 학교 설립 (IZhO13_school) C++17
30 / 100
166 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;

const int nmax = 1e5 + 1;

struct str{
  int a, b;
} v[nmax];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for(int i = 1; i <= n; i ++) {
    cin >> v[i].a >> v[i].b;
  }
  int dp[n + 1][m + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for(int i = 1; i <= n; i ++) {
    for(int j = 0; j <= m; j ++) {
      for(int p = 0; p <= k; p ++) {
        int x = 0;
        dp[i][j][p] = dp[i - 1][j][p];
        if(j != 0) {
          dp[i][j][p] = max(dp[i][j][p], dp[i - 1][j - 1][p] + v[i].a);
        }
        if(p != 0) {
          dp[i][j][p] = max(dp[i][j][p], dp[i - 1][j][p - 1] + v[i].b);
        }
      }
    }
  }
  cout << dp[n][m][k];
  return 0;
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:22:13: warning: unused variable 'x' [-Wunused-variable]
   22 |         int x = 0;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 3676 KB Output is correct
7 Runtime error 154 ms 262144 KB Execution killed with signal 9
8 Runtime error 156 ms 262144 KB Execution killed with signal 9
9 Runtime error 139 ms 262144 KB Execution killed with signal 9
10 Runtime error 144 ms 262144 KB Execution killed with signal 9
11 Runtime error 137 ms 262144 KB Execution killed with signal 9
12 Runtime error 139 ms 262144 KB Execution killed with signal 9
13 Runtime error 149 ms 262144 KB Execution killed with signal 9
14 Runtime error 166 ms 262144 KB Execution killed with signal 9
15 Runtime error 38 ms 3152 KB Execution killed with signal 11
16 Runtime error 39 ms 3220 KB Execution killed with signal 11
17 Runtime error 39 ms 3412 KB Execution killed with signal 11
18 Runtime error 41 ms 3432 KB Execution killed with signal 11
19 Runtime error 39 ms 3344 KB Execution killed with signal 11
20 Runtime error 44 ms 3288 KB Execution killed with signal 11