QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#683838#9528. New Energy Vehiclekano07WA 0ms3708kbC++141.9kb2024-10-28 00:22:292024-10-28 00:22:29

Judging History

This is the latest submission verdict.

  • [2024-10-28 00:22:29]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3708kb
  • [2024-10-28 00:22:29]
  • Submitted

answer

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using db = long double;
mt19937 rnd(time(0));
class JudTime {
public:
    chrono::time_point<chrono::high_resolution_clock> start, end;
    JudTime() : start(chrono::high_resolution_clock::now()) {}
    ~JudTime() {
        end = chrono::high_resolution_clock::now();
        cerr << fixed << setprecision(6) << chrono::duration<double>(end - start).count()
             << " seconds" << endl;
    }
};
const ll N = 1e5 + 5;
ll a[N];
ll b[N];
void solve() {
    ll n, m;
    cin >> n >> m;
    for (ll i = 0; i <= n; i++) a[i] = b[i] = 0;
    for (ll i = 1; i <= n; i++) {
        cin >> b[i];
        a[i] = b[i];
    }
    vector<pll> v;
    v.push_back({0, 0});
    for (ll i = 1; i <= m; i++) {
        ll x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }
    v.push_back({1e13, 0});
    for (ll i = 1; i <= m + 1; i++) {
        ll cost = v[i].first - v[i - 1].first;
        cost -= a[v[i].second];
        a[v[i].second] = b[i];
        for (ll j = i + 1; j <= m; j++) {
            if (cost <= 0) break;
            ll org = a[v[j].second];
            a[v[j].second] = max(0ll, a[v[j].second] - cost);
            cost -= org;
        }
        if (cost > 0) {
            for (ll i = 1; i <= n; i++) {
                if (cost <= 0) break;
                ll org = a[i];
                a[i] = max(0ll, a[i] - cost);
                cost -= org;
            }
        }
        if (cost > 0) {
            cout << v[i - 1].first + (v[i].first - v[i - 1].first - cost) << endl;
            return;
        }
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //   JudTime judTime;
    ll T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

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

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
10
11
1999999998
2000000000

result:

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