QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687727#9528. New Energy VehicleSkyEyeController#WA 0ms3776kbC++232.0kb2024-10-29 20:53:212024-10-29 20:53:23

Judging History

This is the latest submission verdict.

  • [2024-10-29 20:53:23]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3776kb
  • [2024-10-29 20:53:21]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int long long
void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1);
    vector<queue<int>> batpos(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    vector<array<int, 2>> sta(m + 1);
    vector<int> dis(m + 10);
    for (int i = 1; i <= m; i++)
    {
        cin >> sta[i][0] >> sta[i][1];
        dis[i] = sta[i][0];
        batpos[sta[i][1]].push(sta[i][0]);
    }
    dis[m + 1] = 1e18;
    int nowdis = 0;
    priority_queue<array<int, 3>, vector<array<int, 3>>, greater<array<int, 3>>> usage, emp;
    for (int i = 1; i <= n; i++)
    {
        batpos[i].push(LONG_LONG_MAX / 2);
        usage.push({batpos[i].front(), a[i], i});
        batpos[i].pop();
    }
    for (int i = 1; i <= m + 1; i++)
    {
        while (!usage.empty() && nowdis < dis[i])
        {
            auto [pos, vol, id] = usage.top();
            usage.pop();
            if (nowdis + vol <= dis[i])
            {
                nowdis += vol;
                emp.push({pos, 0, id});
            }
            else
            {
                int delta = dis[i] - nowdis;
                nowdis = dis[i];
                if (pos != dis[i])
                    usage.push({pos, vol - delta, id});
                else
                    emp.push({pos, 0, id});
            }
        }
        while (!emp.empty())
        {
            auto [pos, vol, id] = emp.top();
            if (pos == dis[i])
            {
                emp.pop();
                usage.push({batpos[id].front(), a[id], id});
                batpos[id].pop();
            }
            else
                break;
        }
        if (usage.empty())
            break;
    }
    cout << nowdis << endl;
}
signed main()
{
    // freopen("data.in", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}

詳細信息

Test #1:

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

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

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:

9
11
10
11
1999999998
2000000000

result:

wrong answer 3rd lines differ - expected: '4', found: '10'