QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#718730#9528. New Energy VehicleRaislinSnowWA 1ms3596kbC++201.1kb2024-11-06 21:17:542024-11-06 21:17:55

Judging History

This is the latest submission verdict.

  • [2024-11-06 21:17:55]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3596kb
  • [2024-11-06 21:17:54]
  • Submitted

answer

#pragma GCC optimize(3, "Ofast", "inline")
#define FOR(i, a, b) for(int i = (a); i <= (b); i ++)
#define ROF(i, a, b) for(int i = (a); i >= (b); i --)
#define debug(x) cerr << (#x) << ": " << (x) << '\n'
#define pb push_back
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#include <bits/stdc++.h>
 
using namespace std;
 
// #define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef array<int, 2> pii;
typedef array<ll, 2> pll;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

int n, m;
int a[100010];
int x[100010], t[100010];
int d[100010];

void solve(int T) {
	cin >> n >> m;
	FOR(i, 1, n) cin >> a[i];
	FOR(i, 1, m) cin >> x[i] >> t[i];
	FOR(i, 1, m) d[i] = x[i] - x[i - 1];
	int tot = 0;
	FOR(i, 1, n) tot += a[i];
	int now = tot;
	FOR(i, 1, m) {
		now -= d[i];
		if(now < 0) {
			cout << x[i] + now << '\n';
			return;
		}
		now += min(tot - now, a[t[i]]);
	}
	cout << x[m] + now << '\n';
}

void init() {

}

signed main() {
	IOS;
	int t = 1;
	cin >> t;
	init();
	FOR(T, 1, t) {
		solve(T);
	}
  	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'