QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#788615#9528. New Energy VehiclexixuWA 0ms3572kbC++231.4kb2024-11-27 17:40:312024-11-27 17:40:33

Judging History

This is the latest submission verdict.

  • [2024-11-27 17:40:33]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3572kb
  • [2024-11-27 17:40:31]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
#define int long long
// #define int __int128
#define re read()
#define pr(x) print(x)
#define fup(a, b, c, d) for(int a = (b); a <= (c); a += (d))
#define fdo(a, b, c, d) for(int a = (b); a >= (c); a -= (d))
typedef long long ll;
typedef pair<int , int> PII;
typedef map<int , int> MII;
const int inf = 0x3f3f3f3f, N = 2e6 + 10, M = 4e5 + 10, mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;




void solve()
{
    int n, m, su = 0, ssu;
    cin >> n >> m;
    vector<int> a(n + 10);

    fup(i, 1, n, 1) {
        cin >> a[i];
        su += a[i];
    }
    ssu = su;

    vector<PII> v(m + 10);
    fup(i, 1, m, 1) {
        int x, y;
        cin >> x >> y;
        v[i] = {x, y};
    }


    fup(i, 1, m, 1) {
        int lx, ly, x, y;
        lx = v[i - 1].first, x = v[i].first, y = v[i].second;
        if(x - lx <= su) {
            // cout << su << ' ' << a[y] << '\n';
            su -= (x - lx);
            su += min(ssu - su, a[y]);
        }
        else {
            cout << lx + su << '\n';
            return ;
        }
    }
    // cout << su << '\n';
    cout << v[m].first + su << '\n';


}

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int _ = 1;
    cin >> _;
    while(_ --)
    {
        solve();
    }
}

详细

Test #1:

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

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

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'