QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#750260#9528. New Energy VehicleExFolerWA 0ms3648kbC++201.0kb2024-11-15 13:43:262024-11-15 13:43:27

Judging History

This is the latest submission verdict.

  • [2024-11-15 13:43:27]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3648kb
  • [2024-11-15 13:43:26]
  • Submitted

answer

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

const int N=1e5+10;
LL a[N],x[N],t[N];
LL man[N];

void solve()
{
    LL n,m;
    cin >> n >> m;
    
    memset(man,0,(sizeof (LL))*(n+5));
    
    LL sum=0;
    for(LL i=1;i<=n;i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    for(LL i=1;i<=m;i++)
    {
        cin >> x[i] >> t[i];
    }
    
    LL dis=0,ans=0;
    for(LL i=1;i<=m;i++)
    {
        LL d=x[i]-x[i-1];
        dis+=d;
        if(dis>sum) 
        {
            ans=x[i-1]+(sum-(dis-d));
            break;
        }
        LL bus=min(dis,min(x[i] - x[i - 1] -man[t[i]],a[t[i]]));
        dis-=bus;
        dis = max(dis , 0ll) ;
        man[t[i]]=x[i];
    }
    if(dis<=sum) ans=x[m]+(sum-dis);
    
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    
    int T;
    cin >> T;
    while(T--)
    {
        solve();
    }
    
    return 0;
}
/*
1
1 4
1
1 1
2 1
3 1
4 1

*/

詳細信息

Test #1:

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

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

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:

0
11
4
11
999999999
2000000000

result:

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