QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#616396#9446. Construction of Townucup-team5141#WA 0ms33856kbC++231.5kb2024-10-06 04:21:482024-10-06 04:21:48

Judging History

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

  • [2024-10-06 04:21:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:33856kb
  • [2024-10-06 04:21:48]
  • 提交

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 maxn = 105, maxm = 1005;
int dp[2][2*maxm][2*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);
    for (int i=0; i<n-1; ++i) cin >> d[i];

    for (int i=n-2; i>=0; --i) {
        int need = d[i];

        for (int h=0; h<maxm; ++h) {
            for (int o=0; o<maxm; ++o) {
                for (int t=0; t<2; ++t) {

                    if (t) {
                        if (h>=need) {
                            dp[i&1][h][o][t] = min(dp[(i+1)&1][0][o][0], dp[(i+1)&1][0][o][1]);
                        } else {
                            if (o>=need) {
                                dp[i&1][h][o][t] = min(dp[(i+1)&1][0][o-need][0], dp[(i+1)&1][0][o-need][1]);
                            } else {
                                dp[i&1][h][o][t] = min(dp[(i+1)&1][0][0][0], dp[(i+1)&1][0][0][1]) + need - o;
                            }
                        }
                    } else {
                        need = h + d[i];
                        dp[i&1][h][o][t] = min(dp[(i+1)&1][need][o][0], dp[(i+1)&1][need][o][1]) + need;
                    }

                }
            }
        }
    }


    cout << min(dp[0][0][0][0], dp[0][0][0][1]) << '\n';
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 33856kb

input:

3 2
4 5

output:

6

result:

wrong output format Unexpected end of file - int32 expected