QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#686476#9528. New Energy VehiclegaliyuuWA 0ms3536kbC++141.1kb2024-10-29 13:41:562024-10-29 13:41:56

Judging History

This is the latest submission verdict.

  • [2024-10-29 13:41:56]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3536kb
  • [2024-10-29 13:41:56]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n'
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef double db;
mt19937 mrand(random_device{}());
int rnd(int x) {return mrand()%x;}
const ll mod=998244353;
// head

const int N=1e5+10;
ll n,m;
ll a[N];

void solve() {
	cin>>n>>m;
	ll pa=0;
	rep(i,1,n+1) cin>>a[i],pa+=a[i];
	vector<pll> ls(m+1);
	rep(i,1,m+1) {
		cin>>ls[i].fi>>ls[i].se;
	}
	sort(all(ls),[&](pii a,pii b){
		return a.fi<b.fi;
	});
	vl p(n+1);
	ll res=pa,L=0;
	rep(i,1,m+1) {
		ll nl=ls[i].fi,na=ls[i].se;
		if (res<nl) break;
		ll c=min(a[na],nl-L+p[na]);
		p[na]=c-nl;
		L=nl,res+=c;
	}
	cout<<res<<endl;
}

int tc;
signed main() {
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin>>tc;
	while (tc--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

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: 3488kb

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:

5
11
4
11
999999999
2000000000

result:

wrong answer 1st lines differ - expected: '9', found: '5'