QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#616428 | #9446. Construction of Town | ucup-team5141# | WA | 3ms | 19372kb | C++23 | 1.6kb | 2024-10-06 05:19:43 | 2024-10-06 05:19:44 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
using ll = long long;
using lf = long double;
using namespace std;
const int maxm = 1005;
int dp[2][maxm][maxm][2];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int n; cin >> n;
vector<int> d(n, 0);
for (int i=0; i<n-1; ++i) cin >> d[i];
for (int i=n-2; i>=0; --i) {
for (int h=0; h<maxm; ++h) {
for (int o=0; o<maxm; ++o) {
for (int t=0; t<2; ++t) {
dp[i&1][h][o][t] = 1e9;
if (t) {
if (h>=d[i]) {
dp[i&1][h][o][t] = min(dp[(i+1)&1][0][o][0], dp[(i+1)&1][0][o][1]);
} else {
if (o>=d[i]-h) {
dp[i&1][h][o][t] = min(dp[(i+1)&1][0][o - (d[i]-h)][0], dp[(i+1)&1][0][o - (d[i]-h)][1]);
} else {
dp[i&1][h][o][t] = min(dp[(i+1)&1][0][0][0], dp[(i+1)&1][0][0][1]) + d[i]-h - o;
}
}
} else {
int want = h+d[i];
if (want < maxm) {
dp[i&1][h][o][t] = min(dp[(i+1)&1][want][o+d[i]][0], dp[(i+1)&1][want][o+d[i]][1]) + d[i];
}
}
}
}
}
}
cout << min(dp[0][0][0][0], dp[0][0][0][1]) << '\n';
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 19372kb
input:
3 2 4 5
output:
2
result:
wrong output format Unexpected end of file - int32 expected