QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875403#9528. New Energy VehicleMini_PEKKAWA 0ms7908kbC++201.2kb2025-01-29 17:56:122025-01-29 17:56:13

Judging History

This is the latest submission verdict.

  • [2025-01-29 17:56:13]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 7908kb
  • [2025-01-29 17:56:12]
  • Submitted

answer

#include <bits/stdc++.h>
#define se second
#define pb push_back
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll N = 100010;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
ll n, m, a[N], x[N], t[N], _a[N];
vector<ll> p[N];
ll find(ll t, ll x) {
	return *upper_bound(p[t].begin(), p[t].end(), x);
}
void solve() {
	cin >> n >> m;
	rep(i, 1, n) {
		cin >> a[i];
		_a[i] = a[i];
		p[i].clear();
	}
	rep(i, 1, m) {
		cin >> x[i] >> t[i];
		p[t[i]].pb(x[i]);
	}
	rep(i, 1, n) {
		p[i].pb(inf);
	}
	ll cur = 0;
	set<pll> bat;
	rep(i, 1, n) {
		bat.insert({find(i, cur), i});
	}
	x[m + 1] = inf;
	ll i = 1;
	while (1) {
		if (bat.empty()) {
			cout << cur << '\n';
			break;
		}
		ll tp = bat.begin()->se;
		bat.erase(bat.begin());
		if (a[tp] > x[i] - cur) {
			a[tp] -= x[i] - cur;
			cur = x[i];
			bat.insert({find(tp, cur), tp});
			bat.insert({find(t[i], cur), t[i]});
			a[t[i]] = _a[t[i]];
			i++;
		} else {
			cur += a[tp];
			a[tp] = 0;
		}
	}
}
int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	ll t;
	cin >> t;
	rep(i, 1, t) {
		solve();
	}
	return 0;
}

詳細信息

Test #1:

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

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

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:

6
11
4
11
999999999
1000000000

result:

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