QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#685039#9528. New Energy VehicleOrangeQWQWA 0ms3852kbC++201.6kb2024-10-28 17:14:492024-10-28 17:14:49

Judging History

This is the latest submission verdict.

  • [2024-10-28 17:14:49]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3852kb
  • [2024-10-28 17:14:49]
  • Submitted

answer

// 16:30
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>

using namespace std;
using ll = long long;
using PII = pair<int, int>;
#define int long long
// vector<pair<int, int>>

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> p(n);       // i 个电池的电量
    vector<PII> sta(m);     // first 距离 second ai
    map<int, set<int>> ls;  // 第 i 个站,可以冲哪个车车的电
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> sta[i].first >> sta[i].second;
        ls[sta[i].first].insert(sta[i].second);
    }
    sort(sta.begin(), sta.end());

    // int now = accumulate(p.begin(), p.end(), 0ll);  // 当前油量

    vector<pair<int, set<int>>> omg(ls.begin(), ls.end());
    sort(omg.begin(), omg.end(), [&](auto x, auto y) { return x.first < y.first; });
    int now = accumulate(p.begin(), p.end(), 0ll);  // 当前油量
    int maxv = now;
    // cout << 'n' << now << endl;

    int loc = 0;  // 当前距离
    for (auto v : omg) {
        if (now + loc >= v.first) {
            now -= v.first;
            loc = v.first;
            for (auto t : v.second) {
                now += p[t - 1];
            }
            now = min(maxv, now);
        }
        // cout << v.first << ' ' << loc << ' ' << now << endl;
    }
    // cout << now << ' ' << loc << endl;
    cout << loc + now << endl;
}

signed main() {
    cin.tie(nullptr)->ios::sync_with_stdio(false);
    int T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
}

详细

Test #1:

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

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: 3852kb

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:

4
9
4
9
999999999
2000000000

result:

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