QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#691312#9528. New Energy VehicleWA_automaton#WA 0ms3836kbC++201.6kb2024-10-31 10:54:372024-10-31 10:54:37

Judging History

This is the latest submission verdict.

  • [2024-10-31 10:54:37]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3836kb
  • [2024-10-31 10:54:37]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
void debug() {std::cerr << "\n";}
template<class T, class... OtherArgs>
void debug(T &&var, OtherArgs &&... args) {
    std::cerr << std::forward<T>(var) << " ";
    debug(std::forward<OtherArgs>(args)...);
}
#define SZ(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
using i64 = long long;
using u64 = unsigned long long;
using LD = long double;
using PII = pair<int, int>;
constexpr int N = 300010;
constexpr int P = 1e9 + 7;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int tot = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        tot += a[i];
    }
    vector<PII> xt(m);
    for (int i = 0; i < m; i++) {
        auto &[x, t] = xt[i];
        cin >> x >> t;
        t--;
    }

    int ans = 0, lst = 0, add = 0;
    for (int i = 0; i < m; i++) {
        auto &[x, t] = xt[i];

        if (tot < x - lst) {
            ans = lst + tot;
            tot = 0;
            break;
        }
        add += x - lst;
        tot += min(add, a[t]) - (x - lst);
        add -= min(add, a[t]);
        // tot += min(x - lst, a[t]) - (x - lst);
        // debug("?", tot, add);
        lst = ans = x;
    }
    // debug("?", ans, tot);
    ans += tot;
    cout << ans << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(20);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3836kb

input:

2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1

output:

12
9

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3544kb

input:

6
3 2
2 2 2
6 1
7 1
2 2
3 3
2 1
6 2
2 3
2 2
5 1
7 2
9 1
2 2
3 3
2 1
6 2
1 1
999999999
1000000000 1
1 1
1000000000
1000000000 1

output:

10
11
4
11
999999999
2000000000

result:

wrong answer 1st lines differ - expected: '9', found: '10'