QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#682471#9528. New Energy Vehicleucup-team3586#RE 1ms3744kbC++23969b2024-10-27 15:35:142024-10-27 15:35:15

Judging History

This is the latest submission verdict.

  • [2024-10-27 15:35:15]
  • Judged
  • Verdict: RE
  • Time: 1ms
  • Memory: 3744kb
  • [2024-10-27 15:35:14]
  • Submitted

answer

#include<bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
#define int long long
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
const int p=998244353;
int qp(int x,int y)
{
	int res=1;
	for(int t=x; y; y>>=1,t=1ll*t*t%p)
		if(y&1) res=1ll*res*t%p;
	return res;
}
int a[1<<20];
signed main()
{
	for(int T=read();T--;)
	{
		int n=read(),m=read();
		int s=0;
		for(int i=1; i<=n; ++i) a[i]=read(),s+=a[i];
		int lst=0;
		int w=0;
		bool gg=1;
		for(int i=1; i<=m; ++i)
		{
			int x=read(),t=read();
			int dist=x-lst;
			if(w+dist>s) break;
			w+=dist;
			w-=a[t];
			w=max(w,0ll);
			lst=x;
			
		}
		printf("%lld\n",lst+s-w);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3744kb

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

output:


result: