QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#692785#9528. New Energy Vehiclexuxuxuxuxu#WA 1ms7844kbC++141.3kb2024-10-31 15:02:292024-10-31 15:02:30

Judging History

This is the latest submission verdict.

  • [2024-10-31 15:02:30]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7844kb
  • [2024-10-31 15:02:29]
  • Submitted

answer

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>

using std::cin;
using std::cout;

using i64 = long long;
using pii = std::pair<int, int>;

const int nx = 1e5;

int tc;

int n;
int a[nx + 5], b[nx + 5];

int m;
int x[nx + 5], t[nx + 5];
int pv[nx + 5];
std::vector<int> v[nx + 5];

std::set<pii> st;

int main() {
    std::ios::sync_with_stdio(false);

    cin >> tc;
    while (tc--) {
        cin >> n >> m;
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
            v[i].clear();
            pv[i] = 0;
        }
        for (int i = 1; i <= m; ++i) {
            cin >> x[i] >> t[i];
        }
        i64 res = 0, sum = 0, ans = 0;
        for (int i = 1; i <= n; ++i) sum += a[i], b[i] = a[i];
        for (int i = 1; i <= m; ++i) {
            res += x[i] - x[i - 1];
            if (sum >= res) {
                if (b[t[i]] >= res) sum = sum - b[t[i]] + a[t[i]], b[t[i]] = a[t[i]], res = 0;
                else sum = sum - b[t[i]] + a[t[i]], res -= b[t[i]], b[t[i]] = a[t[i]];
            }else {
                ans = x[i - 1] + sum - (res - x[i] + x[i - 1]);
                break;
            }
        }
        if (ans == 0) ans = x[m] + sum - res;
        cout << ans << '\n';
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7844kb

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: 1ms
memory: 6008kb

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'