QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#133901#4931. Comic BingepssxxWA 9ms161864kbC++171.2kb2023-08-02 16:51:032023-08-02 16:51:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 16:51:07]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:161864kb
  • [2023-08-02 16:51:03]
  • 提交

answer

//https://qoj.ac/contest/1019/problem/4931

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e3 + 7;
int T = 1, n, m;
int dp[maxn][maxn * 10][2];
int a[maxn], b[maxn];

void solve(){
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    memset(dp, 0x3f, sizeof dp);
    dp[0][0][0] = 0ll;
    int sumb = 0;
    for(int i = 1; i <= n; i++) {
        sumb += b[i];
        for(int j = 0; j <= sumb; j++) {
            if(j >= b[i]) dp[i][j][1] = max(min(dp[i - 1][j - b[i]][1], dp[i - 1][j - b[i]][0]), j) + a[i];
            dp[i][j][0] = dp[i - 1][j][1] + a[i];
        }
    }
    int ans = inf;
    for(int i = b[i]; i <= n * 10; i++) ans = min(ans, dp[n][i][1]);
    cout << ans << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
 
    // cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 161864kb

input:

6
3 1 1 1 1 2
1 5 3 3 7 4

output:

1061109567

result:

wrong answer 1st lines differ - expected: '13', found: '1061109567'