답안 #967840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967840 2024-04-23T01:49:22 Z josanneo22 Security Guard (JOI23_guard) C++17
12 / 100
70 ms 17340 KB
#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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 49 ms 12812 KB Output is correct
3 Correct 46 ms 12884 KB Output is correct
4 Correct 48 ms 12928 KB Output is correct
5 Correct 46 ms 15648 KB Output is correct
6 Correct 46 ms 15636 KB Output is correct
7 Correct 46 ms 15696 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 49 ms 12812 KB Output is correct
3 Correct 46 ms 12884 KB Output is correct
4 Correct 48 ms 12928 KB Output is correct
5 Correct 46 ms 15648 KB Output is correct
6 Correct 46 ms 15636 KB Output is correct
7 Correct 46 ms 15696 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Incorrect 70 ms 17340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 49 ms 12812 KB Output is correct
3 Correct 46 ms 12884 KB Output is correct
4 Correct 48 ms 12928 KB Output is correct
5 Correct 46 ms 15648 KB Output is correct
6 Correct 46 ms 15636 KB Output is correct
7 Correct 46 ms 15696 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Incorrect 70 ms 17340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 49 ms 12812 KB Output is correct
3 Correct 46 ms 12884 KB Output is correct
4 Correct 48 ms 12928 KB Output is correct
5 Correct 46 ms 15648 KB Output is correct
6 Correct 46 ms 15636 KB Output is correct
7 Correct 46 ms 15696 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Incorrect 70 ms 17340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 49 ms 12812 KB Output is correct
3 Correct 46 ms 12884 KB Output is correct
4 Correct 48 ms 12928 KB Output is correct
5 Correct 46 ms 15648 KB Output is correct
6 Correct 46 ms 15636 KB Output is correct
7 Correct 46 ms 15696 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Incorrect 70 ms 17340 KB Output isn't correct
11 Halted 0 ms 0 KB -