QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#689586 | #9528. New Energy Vehicle | Swd146296# | WA | 1ms | 7792kb | C++17 | 1.7kb | 2024-10-30 17:50:48 | 2024-10-30 17:50:50 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int MX=100020;
const int inf=1e18;
int N, M, T;
int ar[MX], now[MX];
int read()
{
int r=0, f=1; char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
while(ch>='0'&&ch<='9') {r=r*10+ch-'0'; ch=getchar();}
return r*f;
}
struct node
{
int x, t, c;
bool operator < (const node &a)const {return x<a.x;}
}pos[MX];
int top=0;
PII stac[MX];
signed main()
{
// freopen("J.in","r",stdin);
// freopen("J(3).out","w",stdout);
T=read();
while(T--)
{
N=read(); M=read();
int ans=0; top=0;
for(int i=1;i<=N;i++) ar[i]=read(), ans+=ar[i];
for(int i=1;i<=N;i++) now[i]=0;
for(int i=1,use=0;i<=M;i++)
{
pos[i].x=read();
pos[i].t=read();
pos[i].c=min(ar[pos[i].t],pos[i].x-use);
// int l=pos[i].x-pos[i].c, r=pos[i].x; //[l,r] inclusive
// while(top)
// {
// auto [lq,rq]=stac[top];
// cout << "lq=" << lq << ", rq=" << rq << ", l=" << l << ", r=" << r << ", c=" << pos[i].c << '\n';
// if(rq<=l) break;
// pos[i].c-=(rq-max(l,lq)); l=min(l,lq); top--;
// }
// cout << "out, l=" << l << ", r=" << r << ", c=" << pos[i].c << '\n' << '\n';
// stac[++top]={l,r};
use+=pos[i].c;
now[pos[i].t]=pos[i].x;
}
for(int i=1;i<=M;i++)
{
if(ans>=pos[i].x) ans+=pos[i].c;
}
cout << ans << '\n';
}
return (0-0);
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5668kb
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: 7792kb
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'