제출 #1158229

#제출 시각아이디문제언어결과실행 시간메모리
1158229achiFoehn Phenomena (JOI17_foehn_phenomena)C++20
0 / 100
1095 ms2244 KiB
#include <bits/stdc++.h>

using namespace std;

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long int N, Q, S, T;
    long long int L, R, X;
    int i, j;
    long long int deg = 0;
    scanf("%d %d %d %d", &N, &Q, &S, &T);

    vector<long long int> altitiudes(N+1);

    for (i = 0; i < N+1; i++) {
        scanf("%lld", &altitiudes[i]);
        if (i == 0) continue;
        if (altitiudes[i-1] < altitiudes[i]) {
            deg += (altitiudes[i-1] - altitiudes[i])*S;
        }
        else {
            deg += (altitiudes[i-1] - altitiudes[i])*T;
        }
    }

    for (i = 0; i < Q; i++) {
        scanf("%d %d %d", &L, &R, &X);
        if (L-1 >= 0) {
            if (altitiudes[L-1] < altitiudes[L]) {
                deg -= (altitiudes[L-1] - altitiudes[L])*S;
            }
            else {
                deg -= (altitiudes[L-1] - altitiudes[L])*T;
            }

            if (altitiudes[L-1] < (altitiudes[L] + X)) {
                deg += (altitiudes[L-1] - (altitiudes[L] + X))*S;
            }
            else {
                deg += (altitiudes[L-1] - (altitiudes[L] + X))*T;
            }
        }
        if (R+1 <= N) {
            if (altitiudes[R] < altitiudes[R+1]) {
                deg -= (altitiudes[R] - altitiudes[R+1])*S;
            }
            else {
                deg -= (altitiudes[R] - altitiudes[R+1])*T;
            }
            
            if ((altitiudes[R] + X) < altitiudes[R+1]) {
                deg += ((altitiudes[R] + X) - altitiudes[R+1])*S;
            }
            else {
                deg += ((altitiudes[R] + X) - altitiudes[R+1])*T;
            }
        }
        for (j = L; j <= R; j++) {
            altitiudes[j] += X;
        }
        cout << deg << endl;
    }

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:14:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   14 |     scanf("%d %d %d %d", &N, &Q, &S, &T);
      |            ~^            ~~
      |             |            |
      |             int*         long long int*
      |            %lld
foehn_phenomena.cpp:14:16: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   14 |     scanf("%d %d %d %d", &N, &Q, &S, &T);
      |               ~^             ~~
      |                |             |
      |                int*          long long int*
      |               %lld
foehn_phenomena.cpp:14:19: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   14 |     scanf("%d %d %d %d", &N, &Q, &S, &T);
      |                  ~^              ~~
      |                   |              |
      |                   int*           long long int*
      |                  %lld
foehn_phenomena.cpp:14:22: warning: format '%d' expects argument of type 'int*', but argument 5 has type 'long long int*' [-Wformat=]
   14 |     scanf("%d %d %d %d", &N, &Q, &S, &T);
      |                     ~^               ~~
      |                      |               |
      |                      int*            long long int*
      |                     %lld
foehn_phenomena.cpp:30:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   30 |         scanf("%d %d %d", &L, &R, &X);
      |                ~^         ~~
      |                 |         |
      |                 int*      long long int*
      |                %lld
foehn_phenomena.cpp:30:20: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   30 |         scanf("%d %d %d", &L, &R, &X);
      |                   ~^          ~~
      |                    |          |
      |                    int*       long long int*
      |                   %lld
foehn_phenomena.cpp:30:23: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   30 |         scanf("%d %d %d", &L, &R, &X);
      |                      ~^           ~~
      |                       |           |
      |                       int*        long long int*
      |                      %lld
foehn_phenomena.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d %d %d %d", &N, &Q, &S, &T);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%lld", &altitiudes[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d %d %d", &L, &R, &X);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...