답안 #127064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127064 2019-07-08T20:49:17 Z Harry464 Sličice (COCI19_slicice) C++14
90 / 90
148 ms 504 KB
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector <int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  vector <int> b(m+1);
  for (int i = 0; i <= m; i++) cin >> b[i];
  vector <int> dp(k+1,0);
  for (int i = 0; i < n; i++){
    vector <int> dp2(k+1,0);
   for (int j = 0; j <= k; j++){
     for (int s = 0; s <= j; s++){
      int dod = j - s;
      if (p[i] + dod > m) continue;
      dp2[j] = max(dp2[j], dp[s] + b[p[i] + dod]);
     }
   }
   dp = dp2;
  }
  cout << dp[k];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 144 ms 376 KB Output is correct
4 Correct 145 ms 504 KB Output is correct
5 Correct 146 ms 376 KB Output is correct
6 Correct 144 ms 252 KB Output is correct
7 Correct 140 ms 372 KB Output is correct
8 Correct 147 ms 372 KB Output is correct
9 Correct 140 ms 372 KB Output is correct
10 Correct 148 ms 408 KB Output is correct