QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#616428#9446. Construction of Townucup-team5141#WA 3ms19372kbC++231.6kb2024-10-06 05:19:432024-10-06 05:19:44

Judging History

你现在查看的是最新测评结果

  • [2024-10-06 05:19:44]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:19372kb
  • [2024-10-06 05:19:43]
  • 提交

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