# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
796049 | 2023-07-28T05:25:30 Z | 반딧불(#10068) | Security Guard (JOI23_guard) | C++17 | 62 ms | 19028 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m, q; ll arr[200002], ex[400002], ey[400002]; vector<int> link[200002]; ll ans; ll val[200002], dir[200002]; int main(){ scanf("%d %d %d", &n, &m, &q); for(int i=1; i<=n; i++){ scanf("%lld", &arr[i]); } for(int i=1; i<=m; i++){ int x, y; scanf("%d %d", &x, &y); ex[i] = x, ey[i] = y; link[x].push_back(y); link[y].push_back(x); } for(int i=1; i<n; i++){ if(arr[i] <= arr[i+1]) val[i] = arr[i], dir[i] = 0; else val[i] = arr[i+1], dir[i] = 1; } int more = 0; for(int i=1; i<n; i++){ if(dir[i]){ more = 0; continue; } if(more + val[i] < arr[i+1]) val[i] += arr[i+1] - (more + val[i]); more = val[i] - arr[i+1] - more; } more = 0; for(int i=n-1; i>=1; i--){ if(more + val[i] < arr[i]) val[i] += arr[i] - (more + val[i]); more = val[i] - arr[i] - more; } for(int i=1; i<n; i++) ans += val[i]; printf("%lld", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 60 ms | 19000 KB | Output is correct |
3 | Correct | 60 ms | 18992 KB | Output is correct |
4 | Incorrect | 62 ms | 19028 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 60 ms | 19000 KB | Output is correct |
3 | Correct | 60 ms | 18992 KB | Output is correct |
4 | Incorrect | 62 ms | 19028 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 60 ms | 19000 KB | Output is correct |
3 | Correct | 60 ms | 18992 KB | Output is correct |
4 | Incorrect | 62 ms | 19028 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 60 ms | 19000 KB | Output is correct |
3 | Correct | 60 ms | 18992 KB | Output is correct |
4 | Incorrect | 62 ms | 19028 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 60 ms | 19000 KB | Output is correct |
3 | Correct | 60 ms | 18992 KB | Output is correct |
4 | Incorrect | 62 ms | 19028 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |