QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#732488#9528. New Energy VehicleCorycle#WA 0ms5828kbC++20938b2024-11-10 14:49:022024-11-10 14:49:02

Judging History

This is the latest submission verdict.

  • [2024-11-10 14:49:02]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 5828kb
  • [2024-11-10 14:49:02]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int read(){
    int x=0,f=1;char c=getchar();
    while((c<'0'||c>'9')&&c!='-') c=getchar();
    if(c=='-') f=-1,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return f*x;
}
int n,m,X,S,curpos;
int a[100005];
struct St{
    int pos,t;
}b[100005];
bool cmppos(St a,St b){
    if(a.pos==b.pos) a.t<b.t;
    return a.pos<b.pos;
}
void work(){
    n=read();m=read();X=0;curpos=0;S=0;
    for(int i=1;i<=n;++i) a[i]=read(),S+=a[i];
    for(int i=1;i<=m;++i){
        b[i].pos=read();
        b[i].t=read();
    }
    sort(b+1,b+m+1,cmppos);
    for(int i=1;i<=m;++i){
        if(S-X+curpos<b[i].pos) break;
        X+=b[i].pos-curpos;
        if(X>=a[b[i].t]) X-=a[b[i].t];
        else X=0;
        curpos=b[i].pos;
    }
    printf("%lld\n",S-X+curpos);
}
signed main(){
    int T=read();
    while(T--) work();
}

詳細信息

Test #1:

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

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

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'