이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;
#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 4005
int n, d, t;
int ti[MAXN];
int cost[MAXN][MAXN];
ll dp[MAXN][MAXN];
int main() {
scanf("%d%d%d", &n, &d, &t);
REP (i, 1, n + 1) {
scanf("%d", &ti[i]);
}
REP (i, 1, n + 1) {
ll r = -1;
int cur = 0;
REP (j, i, n + 1) {
if (t >= ti[j]) mxto(r, t - ti[j] + j);
if (r >= j) cur++;
cost[i][j] = cur;
}
}
REP (i, 1, n + 1) {
dp[i][0] = cost[1][i];
REP (j, 1, d + 1) {
dp[i][j] = LINF;
REP (k, 1, i) {
mnto(dp[i][j], dp[k][j - 1] + cost[k + 1][i]);
}
}
}
printf("%lld\n", dp[n][d]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
prison.cpp: In function 'int main()':
prison.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | scanf("%d%d%d", &n, &d, &t);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
prison.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | scanf("%d", &ti[i]);
| ~~~~~^~~~~~~~~~~~~~
# | 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... |