제출 #1179594

#제출 시각아이디문제언어결과실행 시간메모리
1179594pythontestFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
81 ms7240 KiB
#include <iostream>
constexpr int N=2e5+10;
long long vals[N];
long long deltas[N];
long long n,q,s,t;
void handledeltas(long long &wyn, long long deltav, int wsp=1){
    if(deltav>0) wyn-=s*deltav*wsp;
    else wyn-=t*deltav*wsp;
}
int main() {
    scanf("%d %d %d %d",&n,&q,&s,&t);
    for(int i=0;i<=n;i++)scanf("%lld",&vals[i]);
    for(int i=1;i<=n;i++) deltas[i]=vals[i]-vals[i-1];
    long long wyn=0;
    for(int i=1;i<=n;i++) handledeltas(wyn,deltas[i]);
    for(int i=0;i<q;i++){
        int a,b,d;
        scanf("%d %d %d",&a,&b,&d);
        handledeltas(wyn,deltas[a],-1);
        if(b+1<=n) handledeltas(wyn,deltas[b+1],-1);
        deltas[a]+=d;
        deltas[b+1]-=d;
        handledeltas(wyn,deltas[a],1);
        if(b+1<=n) handledeltas(wyn,deltas[b+1],1);
        printf("%lld\n",wyn);
    }
    return 0;
}

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:11:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   11 |     scanf("%d %d %d %d",&n,&q,&s,&t);
      |            ~^           ~~
      |             |           |
      |             int*        long long int*
      |            %lld
foehn_phenomena.cpp:11:16: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   11 |     scanf("%d %d %d %d",&n,&q,&s,&t);
      |               ~^           ~~
      |                |           |
      |                int*        long long int*
      |               %lld
foehn_phenomena.cpp:11:19: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   11 |     scanf("%d %d %d %d",&n,&q,&s,&t);
      |                  ~^           ~~
      |                   |           |
      |                   int*        long long int*
      |                  %lld
foehn_phenomena.cpp:11:22: warning: format '%d' expects argument of type 'int*', but argument 5 has type 'long long int*' [-Wformat=]
   11 |     scanf("%d %d %d %d",&n,&q,&s,&t);
      |                     ~^           ~~
      |                      |           |
      |                      int*        long long int*
      |                     %lld
foehn_phenomena.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %d %d %d",&n,&q,&s,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(int i=0;i<=n;i++)scanf("%lld",&vals[i]);
      |                          ~~~~~^~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d %d %d",&a,&b,&d);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...