#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
const int nax = 200005;
int N, M, Q;
i64 S[nax];
vector<int> G[nax];
namespace subtask1 {
void solve() {
i64 ans = 0;
for (int i = 2; i <= N; i++) ans += max(S[i], S[i - 1]);
for (int i = 1; i < N; i++) ans -= max(0LL, S[i] - S[i + 1]);
cout << ans << '\n';
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
cin >> N >> M >> Q;
for (int i = 1; i <= N; i++) cin >> S[i];
for (int i = 0; i < M; i++) {
int u, v; cin >> u >> v;
G[u].push_back(v);
G[v].push_back(u);
}
if (M == N - 1 && Q == 0 && *max_element(S + 1, S + 1 + N) <= 2) subtask1::solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
46 ms |
15704 KB |
Output is correct |
3 |
Correct |
53 ms |
15656 KB |
Output is correct |
4 |
Incorrect |
45 ms |
15644 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
46 ms |
15704 KB |
Output is correct |
3 |
Correct |
53 ms |
15656 KB |
Output is correct |
4 |
Incorrect |
45 ms |
15644 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
46 ms |
15704 KB |
Output is correct |
3 |
Correct |
53 ms |
15656 KB |
Output is correct |
4 |
Incorrect |
45 ms |
15644 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
46 ms |
15704 KB |
Output is correct |
3 |
Correct |
53 ms |
15656 KB |
Output is correct |
4 |
Incorrect |
45 ms |
15644 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
46 ms |
15704 KB |
Output is correct |
3 |
Correct |
53 ms |
15656 KB |
Output is correct |
4 |
Incorrect |
45 ms |
15644 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |