QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#711552#9528. New Energy Vehicleucup-team1329#WA 0ms3544kbC++172.6kb2024-11-05 12:01:232024-11-05 12:01:23

Judging History

This is the latest submission verdict.

  • [2024-11-05 12:01:23]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3544kb
  • [2024-11-05 12:01:23]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define all1(x) x.begin() + 1, x.end()
#define bit1(x) __builtin_popcountll(x)
#define Pqueue priority_queue
#define lc p << 1
#define rc p << 1 | 1
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define fi first
#define se second
#define lowbit(x) (x & -x)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;

const ll mod = 1000000007;
const ll N = 1e6 + 10;
const ld eps = 1e-9;
const ll inf = 1e18;
const ll P = 131;
const ll dir[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<ll> a(n + 1);
    ll tot = 0;
    for (int i = 1; i <= n; i++)
        cin >> a[i],tot+=a[i];
    vector<ll> x(m + 1), t(m + 1);
    for (int i = 1; i <= m; i++)
        cin >> x[i] >> t[i];
    for (int i = m; i > 1; i--)
        x[i] = x[i] - x[i - 1];

    ll sum = 0, pos = 0;

    for (int i = 1; i <= m; i++)
    {
        if (sum + x[i] <= tot)
        {
            sum = max(0ll, sum + x[i] - a[t[i]]);
        }
        else
        {
            cout << pos + tot - sum << "\n";
            return;
        }
        // cout << sum << " ";
        pos += x[i];
    }
    cout << pos + tot - sum << "\n";
}

/*
2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1
*/

int main()
{
    IOS int T = 1;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

/*
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
x                                                                                      o
o       _/_/_/_/                                                              _/       x
x      _/                                                                              o
o     _/_/_/_/ _/  _/_/   _/_/   _/_/_/ _/_/   _/_/_/     _/_/    _/_/_/    _/ _/   _/ x
x    _/       _/_/     _/    _/ _/   _/   _/  _/    _/ _/    _/  _/    _/  _/   _/ _/  o
o   _/       _/       _/    _/ _/   _/   _/  _/    _/ _/    _/  _/    _/  _/    _/_/   x
x  _/       _/         _/_/   _/   _/   _/  _/_/_/     _/_/ _/ _/    _/  _/      _/    o
o                                          _/                           _/      _/     x
x                                         _/                        _/_/       _/      o
o                                                                                      x
xoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxo
*/

詳細信息

Test #1:

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

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

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'