제출 #979890

#제출 시각아이디문제언어결과실행 시간메모리
979890peraFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
454 ms11344 KiB
#include<bits/stdc++.h> #define int long long using namespace std; const int N = 2e5 + 1; int n , q , S , T , sum = 0; vector<int> A(N) , t(N); void add(int u , int x){ while(u <= n){ t[u] += x; u += u&-u; } } int get(int u){ int s = 0; while(u > 0){ s += t[u]; u -= u&-u; } return s; } main(){ cin >> n >> q >> S >> T; auto value = [&](int i){ return (A[i] > A[i - 1] ? -S * (A[i] - A[i - 1]) : T * (A[i - 1] - A[i])); }; cin >> A[0]; for(int i = 1;i <= n;i ++){ cin >> A[i]; add(i , A[i]); if(i < n){ add(i + 1 , -A[i]); } sum += value(i); } while(q--){ int l , r , x; cin >> l >> r >> x; add(l , x); if(r + 1 < n){ add(r + 1 , -x); } if(r < n){ sum -= value(r + 1); A[r] = get(r); A[r + 1] = get(r + 1); sum += value(r + 1); } sum -= value(l); A[l] = get(l); A[l - 1] = get(l - 1); sum += value(l); cout << sum << endl; } }

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

foehn_phenomena.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...