QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#678773#9528. New Energy Vehicleucup-team1769#WA 0ms3528kbC++201.4kb2024-10-26 16:06:332024-10-26 16:06:34

Judging History

This is the latest submission verdict.

  • [2024-10-26 16:06:34]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3528kb
  • [2024-10-26 16:06:33]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e6;

signed main()
{
    IOS;
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vector<int> v(n + 1);
        vector<pii> c(m + 1);
        int now = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> v[i];
            now += v[i];
        }
        for (int i = 1; i <= m; i++)
        {
            auto &[fi, se] = c[i];
            cin >> fi >> se;
        }
        sort(c.begin(),c.end());
        int ans = now;
        int f = 0;
        for (int i = 1; i <= m; i++)
        {
            auto [nfi, nse] = c[i];
            auto [qfi, qse] = c[i - 1];

            if (now >= nfi - qfi)
            {
                if (nfi - f >= v[nse])
                {
                    f += v[nse];
                    ans += v[nse];
                    now -= nfi - qfi - v[nse];
                }
                else
                {
                    int _=nfi - f;
                    f += _;
                    ans += _;
                    now -= nfi - qfi - _;
                }
            }
            else
                break;
        }
        cout<<ans<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'