QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#683180#9528. New Energy Vehiclewoodie_0064#WA 0ms3856kbC++201.3kb2024-10-27 19:17:232024-10-27 19:17:24

Judging History

This is the latest submission verdict.

  • [2024-10-27 19:17:24]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3856kb
  • [2024-10-27 19:17:23]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
int T;
int n, num;

typedef long long ll;
void work(){
	int n,m;cin >> n >> m;
	vector <ll> a(n),vis(n);
	for(auto &x : a) cin >> x;
	vector <ll> c = a;
	vector <pair <ll,ll>> b(m);
	for(auto &[x,y] : b) {
		cin >> x >> y,y -= 1;
		vis[y] = 1;
	}
	b.push_back({1e18,0});
	ll sum = 0;
	for(int i = 0;i < n;i++) if(!vis[i]) {
		sum += a[i];
		a[i] = 0;
	}
	multiset <int> st;
	int j = 0;
	ll pos = 0;
	for(int i = 0;i < m;i++) {
		j = max(j,i);
		while(j < m) {
			ll val = min(a[b[j].second],b[i].first - pos);
			pos += val;
			a[b[j].second] -= val;
			if(a[b[j].second]) break;
			st.insert(b[j].second);
			j += 1;
		}
//		cout << j << ' ' << << '\n';
		ll dis = min(b[i].first - pos,sum);
		pos += dis;
		sum -= dis;
		if(st.find(b[i].second) != st.end()) st.erase(st.find(b[i].second));
		a[b[i].second] = c[b[i].second];
		if(st.find(b[i].second) != st.end()) {
			dis = min(a[b[i].second],b[i + 1].first - b[i].first);
			pos += dis;
			a[b[i].second] -= dis;
		}
	}
	for(int i = 0;i < n;i++) pos += a[i];
	cout << pos + sum << '\n';

}


int main(){
//	freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> T;
	while(T--){
		work();
	}	
	return 0;
}

詳細信息

Test #1:

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

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

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:

9
11
10
11
1999999998
2000000000

result:

wrong answer 3rd lines differ - expected: '4', found: '10'