Submission #967840

#TimeUsernameProblemLanguageResultExecution timeMemory
967840josanneo22Security Guard (JOI23_guard)C++17
12 / 100
70 ms17340 KiB
#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]; i64 solve1() { i64 ans = 0; for (int i = 2; i <= N; i++) ans += max(S[i], S[i - 1]); for (int i = 1; i <= N - 2; i++) ans -= max(0LL, S[i] - S[i + 1]); return ans; } 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); } i64 ans = solve1(); reverse(S + 1, S + 1 + N); ans = max(ans, solve1()); cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...