Submission #636981

# Submission time Handle Problem Language Result Execution time Memory
636981 2022-08-31T00:55:50 Z iee Sličice (COCI19_slicice) C++17
90 / 90
45 ms 1272 KB
// iee
#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = (a), i##END = (b); i <= (i##END); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using namespace std;
void work(int);

template <class T> void read(T &x) {
  x = 0;
  int f = 1, ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  x *= f;
}

int main() {
  int TT = 1; // cin >> TT;
  rep(CAS, 1, TT)
    work(CAS);
  return 0;
}
const int N = 505;
int n, m, k, p[N], b[N], f[N][N];
void work(int CASE) {
  cin >> n >> m >> k;
  rep(i, 1, n) cin >> p[i];
  rep(i, 0, m) cin >> b[i];
  rep(i, 1, n) rep(j, 0, k) rep(t, 0, min({m - p[i], k, j}))
    f[i][j] = max(f[i][j], f[i - 1][j - t] + b[p[i] + t]);
  cout << *max_element(f[n], f[n] + N);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 44 ms 1200 KB Output is correct
4 Correct 44 ms 1168 KB Output is correct
5 Correct 44 ms 1272 KB Output is correct
6 Correct 43 ms 1256 KB Output is correct
7 Correct 44 ms 1208 KB Output is correct
8 Correct 45 ms 1172 KB Output is correct
9 Correct 44 ms 1204 KB Output is correct
10 Correct 45 ms 1208 KB Output is correct