QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#446223#8781. Element-Wise ComparisonandoWA 53ms140092kbC++20901b2024-06-17 02:02:152024-06-17 02:02:16

Judging History

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

  • [2024-06-17 02:02:16]
  • 评测
  • 测评结果:WA
  • 用时:53ms
  • 内存:140092kb
  • [2024-06-17 02:02:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5 + 10, INF = 1e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n; cin >> n;
    vector<int> a(n + 1), b(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<vector<int>> dp(n + 1, vector<int>(5e6 + 1, INF));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 5e6; j++) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j] + b[i]);
            if (j >= a[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - a[i]]);
        }
    }
    int mi = INF;
    for (int i = 0; i <= 5e6; i++) {
        mi = min(mi, max(dp[n][i], i));
    }
    cout << mi;
    return 0;
}


詳細信息

Test #1:

score: 0
Wrong Answer
time: 53ms
memory: 140092kb

input:

5 3
5 2 1 3 4

output:

5

result:

wrong answer expected '0', found '5'