QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#685755 | #9528. New Energy Vehicle | iscreamc3 | WA | 1ms | 7736kb | C++17 | 4.4kb | 2024-10-28 21:08:25 | 2024-10-28 21:08:25 |
Judging History
answer
//#include <bits/stdc++.h>
//using namespace std;
//#define int long long
//const int N=1e6+10;
//int a[N];
//signed main() {
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr), cout.tie(nullptr);
//
// int t;
// cin >> t;
// while (t--) {
// int n;cin>>n;
// map<char,int>mp;
// vector<pair<char,int>>res;
// char to;
// for(int i=1;i<=n;i++){
// char a;
// int x;cin>>a>>x;
// if(i==1) {
// res.push_back({a, x});
// res.push_back({'Z',x});
// }else {
//
// if (a == 'N') {
// res.push_back({'Z', x});
// } else if (a == 'E') {
// res.push_back({'L', 0});
// res.push_back({'Z', x});
// } else if (a == 'W') {
// res.push_back({'R', 0});
// res.push_back({'Z', x});
// }
//
//// } else if (to == 'S') {
//// if (a == 'S')
//// res.push_back({'Z', x});
//// else if (a == 'E') {
//// res.push_back({'R', 0});
//// res.push_back({'Z', x});
//// } else if (a == 'W') {
//// res.push_back({'L', 0});
//// res.push_back({'Z', x});
//// }
//// }else if(to=='W'){
//// if(a=='W')
//// res.push_back({'Z',x});
//// else if(a=='N'){
//// res.push_back({'L',0});
//// res.push_back({'Z', x});
//// }else if(a=='S'){
//// res.push_back({'R',0});
//// res.push_back({'Z', x});
//// }
//// }else{
//// if(a=='E')
//// res.push_back({'Z',x});
//// else if(a=='N'){
//// res.push_back({'R',0});
//// res.push_back({'Z', x});
//// }else if(a=='S'){
//// res.push_back({'L',0});
//// res.push_back({'Z', x});
//// }
//// }
//// to=a;
// }
// }
// cout<<res.size()-1<<" "<<res[0].first<<'\n';
// for(int i=0;i<res.size();i++){
// if(i==0)continue;
// if(res[i].second==0)
// cout<<res[i].first<<'\n';
// else
// cout<<res[i].first<<" "<<res[i].second<<'\n';
// }
// }
//}
#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];
b[i]=0;
}else{
continue;
}
int u=i;
while(idx>=a[pre].first){
if(a[pre].second==u){
res=a[pre].first;
}else{
res=idx;
}
idx=res+c[a[pre].second];
res=idx;
u=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: 7724kb
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: 7736kb
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:
9 11 4 11 999999999 2000000003
result:
wrong answer 6th lines differ - expected: '2000000000', found: '2000000003'