QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#679358 | #9528. New Energy Vehicle | ucup-team134# | RE | 0ms | 3884kb | C++17 | 916b | 2024-10-26 17:26:50 | 2024-10-26 17:26:51 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128
using namespace std;
mt19937 rng(time(NULL));
int main()
{
ios;
int t;
cin >> t;
while(t--){
int n,m;
cin >> n >> m;
ll b=0;
vector<int> a(n);
for(int i=0;i<n;i++){
cin >> a[i];
b+=a[i];
}
ll potrosio=0;
int p=0;
bool done=0;
for(int i=0;i<m;i++){
int x,t;
cin >> x >> t;
int d=x-p;
if(potrosio+d>b){
printf("%lld\n",p+b-potrosio);
done=1;
break;
}
potrosio+=d;
int ref=a[t-1];
potrosio=max(0LL,potrosio-ref);
p=x;
}
if(!done){
printf("%lld\n",p+b-potrosio);
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3884kb
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
Runtime Error
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