이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define pb push_back
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
const int N = 2e6+5;
int n, a[N], d, t;
vector<vector<vector<ll>>> dp;
ll sol(int i, int rem, int ls) {
if (rem < 0)return n;
if (i == n)return 0;
ll &ret = dp[i][rem][ls];
if (~ret)return ret;
ret = sol(i+1, rem, ls) + (min(a[ls]+i-ls, a[i]) <= t);
ret = min(ret, sol(i+1, rem-1, i+1) + (min(a[ls]+i-ls, a[i]) <= t));
return ret;
}
int main () {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> d >> t;
int ans = 0;
int cnt = 0;
multiset<int, greater<>> s;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
dp.resize(n);
for (int i = 0; i < n; i++) {
dp[i].resize(d+1);
for (int j = 0; j <= d; j++) {
dp[i][j].resize(n);
for (int k = 0; k < n; k++) {
dp[i][j][k] = -1;
}
}
}
cout << sol(0, d, 0) << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
prison.cpp: In function 'int main()':
prison.cpp:28:6: warning: unused variable 'ans' [-Wunused-variable]
28 | int ans = 0;
| ^~~
prison.cpp:29:6: warning: unused variable 'cnt' [-Wunused-variable]
29 | int cnt = 0;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |