QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124114#6342. Security GuardAdam_GS#0 0ms0kbC++17835b2023-07-14 08:16:182024-07-04 00:39:07

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 00:39:07]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 08:16:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e5+7;
ll T[LIM], odw[LIM], ans;
vector<int>V[LIM];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m, q;
	cin >> n >> m >> q;
	rep(i, n) cin >> T[i];
	rep(i, m) {
		int a, b;
		cin >> a >> b; --a; --b;
		V[a].pb(b);
		V[b].pb(a);
		ans+=min(T[a], T[b]);
	}
	pair<ll,int>ma={-1, -1};
	rep(i, n) ma=max(ma, {T[i], i});
	priority_queue<pair<ll,ll>>Q;
	Q.push({0, ma.nd});
	while(!Q.empty()) {
		ll o=-Q.top().st, p=Q.top().nd;
		if(odw[p]) continue;
		odw[p]=1;
		ans+=o;
		for(auto i : V[p]) if(!odw[i]) Q.push({-max(T[p]-T[i], 0ll), i});
	}
	cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

200000 199999 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Time Limit Exceeded

Test #85:

score: 0
Time Limit Exceeded

input:

16 15 200000
692461146 622302385 805066691 422290641 600839873 940930580 873147413 489653843 239129952 383473127 21389393 913787109 856138328 859082963 262475462 327598064
6 13
6 9
6 15
6 14
6 16
6 8
5 6
1 6
4 6
3 6
6 11
6 7
6 10
2 6
6 12

output:


result:


Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%