QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#685673 | #9528. New Energy Vehicle | xfs001 | WA | 1ms | 7756kb | C++14 | 1.4kb | 2024-10-28 20:43:39 | 2024-10-28 20:43:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;
pair<int,int> a[N];
int b[N],c[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>b[i];
c[i]=b[i];
}
for(int i=1;i<=m;i++){
cin>>a[i].first>>a[i].second;
}
sort(a+1,a+m+1);
int res=0,pre=1,idx=0;
for(int i=1;i<=m;i++){
if(a[i].first>b[a[i].second]){
res+=b[a[i].second];
idx+=b[a[i].second];
b[a[i].second]=0;
}else{
res+=a[i].first-idx;
idx=a[i].first;
}
while(idx>=a[pre].first){
b[a[pre].second]=c[a[pre].second];
pre++;
if(pre>m)break;
}
}
for(int i=1;i<=n;i++){
if(b[i]){
idx+=b[i];
}else{
continue;
}
while(idx>=a[pre].first){
b[a[pre].second]=c[a[pre].second];
pre++;
if(pre>m)break;
}
}
for(int i=1;i<=n;i++){
res+=b[i];
}
cout<<res<<"\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7756kb
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: 1ms
memory: 7668kb
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:
8 11 4 11 999999999 2000000000
result:
wrong answer 1st lines differ - expected: '9', found: '8'