# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
796053 | 2023-07-28T05:29:13 Z | 반딧불(#10068) | Security Guard (JOI23_guard) | C++17 | 73 ms | 19116 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 = more + val[i] - arr[i+1]; } more = 0; for(int i=n-1; i>=1; i--){ if(more + val[i] < arr[i]) val[i] += arr[i] - (more + val[i]); more = more + val[i] - arr[i]; } for(int i=1; i<n; i++) ans += val[i]; printf("%lld", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 64 ms | 19076 KB | Output is correct |
3 | Correct | 65 ms | 18988 KB | Output is correct |
4 | Correct | 65 ms | 18976 KB | Output is correct |
5 | Correct | 66 ms | 19032 KB | Output is correct |
6 | Correct | 64 ms | 19084 KB | Output is correct |
7 | Correct | 65 ms | 19056 KB | Output is correct |
8 | Correct | 3 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 64 ms | 19076 KB | Output is correct |
3 | Correct | 65 ms | 18988 KB | Output is correct |
4 | Correct | 65 ms | 18976 KB | Output is correct |
5 | Correct | 66 ms | 19032 KB | Output is correct |
6 | Correct | 64 ms | 19084 KB | Output is correct |
7 | Correct | 65 ms | 19056 KB | Output is correct |
8 | Correct | 3 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 73 ms | 18996 KB | Output is correct |
11 | Correct | 69 ms | 19016 KB | Output is correct |
12 | Correct | 69 ms | 18992 KB | Output is correct |
13 | Correct | 69 ms | 19072 KB | Output is correct |
14 | Correct | 72 ms | 19116 KB | Output is correct |
15 | Correct | 70 ms | 19032 KB | Output is correct |
16 | Correct | 70 ms | 18980 KB | Output is correct |
17 | Correct | 71 ms | 19020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 64 ms | 19076 KB | Output is correct |
3 | Correct | 65 ms | 18988 KB | Output is correct |
4 | Correct | 65 ms | 18976 KB | Output is correct |
5 | Correct | 66 ms | 19032 KB | Output is correct |
6 | Correct | 64 ms | 19084 KB | Output is correct |
7 | Correct | 65 ms | 19056 KB | Output is correct |
8 | Correct | 3 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 73 ms | 18996 KB | Output is correct |
11 | Correct | 69 ms | 19016 KB | Output is correct |
12 | Correct | 69 ms | 18992 KB | Output is correct |
13 | Correct | 69 ms | 19072 KB | Output is correct |
14 | Correct | 72 ms | 19116 KB | Output is correct |
15 | Correct | 70 ms | 19032 KB | Output is correct |
16 | Correct | 70 ms | 18980 KB | Output is correct |
17 | Correct | 71 ms | 19020 KB | Output is correct |
18 | Incorrect | 3 ms | 4948 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 64 ms | 19076 KB | Output is correct |
3 | Correct | 65 ms | 18988 KB | Output is correct |
4 | Correct | 65 ms | 18976 KB | Output is correct |
5 | Correct | 66 ms | 19032 KB | Output is correct |
6 | Correct | 64 ms | 19084 KB | Output is correct |
7 | Correct | 65 ms | 19056 KB | Output is correct |
8 | Correct | 3 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 73 ms | 18996 KB | Output is correct |
11 | Correct | 69 ms | 19016 KB | Output is correct |
12 | Correct | 69 ms | 18992 KB | Output is correct |
13 | Correct | 69 ms | 19072 KB | Output is correct |
14 | Correct | 72 ms | 19116 KB | Output is correct |
15 | Correct | 70 ms | 19032 KB | Output is correct |
16 | Correct | 70 ms | 18980 KB | Output is correct |
17 | Correct | 71 ms | 19020 KB | Output is correct |
18 | Incorrect | 3 ms | 4948 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 64 ms | 19076 KB | Output is correct |
3 | Correct | 65 ms | 18988 KB | Output is correct |
4 | Correct | 65 ms | 18976 KB | Output is correct |
5 | Correct | 66 ms | 19032 KB | Output is correct |
6 | Correct | 64 ms | 19084 KB | Output is correct |
7 | Correct | 65 ms | 19056 KB | Output is correct |
8 | Correct | 3 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 73 ms | 18996 KB | Output is correct |
11 | Correct | 69 ms | 19016 KB | Output is correct |
12 | Correct | 69 ms | 18992 KB | Output is correct |
13 | Correct | 69 ms | 19072 KB | Output is correct |
14 | Correct | 72 ms | 19116 KB | Output is correct |
15 | Correct | 70 ms | 19032 KB | Output is correct |
16 | Correct | 70 ms | 18980 KB | Output is correct |
17 | Correct | 71 ms | 19020 KB | Output is correct |
18 | Incorrect | 3 ms | 4948 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |