QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#687400 | #9528. New Energy Vehicle | 523555337 | WA | 1ms | 7800kb | C++14 | 1.1kb | 2024-10-29 18:51:11 | 2024-10-29 18:51:12 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define endl '\n'
using namespace std;
const int N=3e5+10,INF=1e14,mod=1e9+7,M=2e5+10;
const double eps = 1e-8;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int qmi(int a,int k){int res=1;while(k){if(k&1) res=res*a%mod;a=a*a%mod;k>>=1;}return res;}
int a[N],x[N],t[N];
map<int,int> ls;
void slove(){
int n,m;cin>>n>>m;
ls.clear();
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=m;i++) cin>>x[i]>>t[i];
int sum=0,dis=0;
for(int i=1;i<=n;i++) sum+=a[i];
dis=sum;//dis中途最大优良
int ans=0;
for(int i=1;i<=m;i++){
dis-=(x[i]-x[i-1]);
//int ju=x[i]-ls[t[i]];//跟上次
if(dis<0){
dis+=(x[i]-x[i-1]);
cout<<x[i-1]+dis<<endl;
return ;
}
int no=min(sum-dis,a[t[i]]);//距离和上次相同距离
no=min(no,a[t[i]]);
dis+=no;
//ls[t[i]]=x[i];
}
cout<<x[m]+dis<<endl;
}
/*
2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1
*/
signed main(){
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int T=1;cin>>T;
while(T--) slove();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7800kb
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: 7676kb
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'