QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#511595#5384. Floppy MusicdarrkeerWA 0ms3764kbC++141.2kb2024-08-10 06:12:172024-08-10 06:12:17

Judging History

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

  • [2024-08-10 06:12:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3764kb
  • [2024-08-10 06:12:17]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

constexpr int INF = 1e9;

void solve() {
    int t, n; cin >> t >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) {
        int a, b; cin >> a >> b;
        v[i] = b - a;
    }
    vector<vector<int>> dp(n, vector<int>(t + 1, INF));
    dp[0][v[0]] = v[0];
    dp[0][0] = v[0];
    for(int i=0; i<n - 2; ++i) {
        for(int j=0; j<=t; ++j) {
            if(dp[i][j] == INF) {
                continue;
            }
            int len = dp[i][j];
            int r = j + v[i + 1];
            if(r <= t) {
                dp[i + 1][r] = min({dp[i + 1][r], r, len});
            }
            if(j < v[i + 1] && v[i + 1] + len - j <= t) {
                dp[i + 1][0] = min({dp[i + 1][0], v[i + 1] + len - j});
            } else {
                int l = j - v[i + 1];
                dp[i + 1][l] = min({dp[i + 1][l], len});
            }
        }
    }
    int mn = INF;
    for(int j=0; j<=t; ++j) {
        mn = min(mn, dp[n - 1][j]);
    }
    if(mn > t) {
        cout << "impossible\n";
        exit(0);
    }
}

int main() {
    int f; cin >> f;
    for(int i=0; i<f; ++i) {
        solve();
    }
    cout << "possible\n";
}

详细

Test #1:

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

input:

1
6 2
0 4
6 12

output:

impossible

result:

wrong answer 1st lines differ - expected: 'possible', found: 'impossible'