답안 #796049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796049 2023-07-28T05:25:30 Z 반딧불(#10068) Security Guard (JOI23_guard) C++17
0 / 100
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

guard.cpp: In function 'int main()':
guard.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d %d %d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
guard.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%lld", &arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
guard.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 -