제출 #791191

#제출 시각아이디문제언어결과실행 시간메모리
791191IsaLFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
85 ms13152 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long, long long> // jangan kebiasa kalah // kalo OI, sampah aja dulu, tapi jangan menutup kemungkinan buat AC long long n,q,s,t,arr[200069],diff[200069],sms,smt; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); long long i,j; cin>>n>>q>>s>>t; for(i=0;i<=n;i++) { cin>>arr[i]; } for(i=1;i<=n;i++) { diff[i] = arr[i]-arr[i-1]; if(diff[i] > 0) { sms += diff[i]; } else { smt += abs(diff[i]); } } while(q--) { long long l,r,x; cin>>l>>r>>x; // netralin dulu if(diff[l] > 0) { sms -= diff[l]; } else { smt -= abs(diff[l]); } // ubah nilai idx ke L diff[l] += x; if(diff[l] > 0) { sms += diff[l]; } else { smt += abs(diff[l]); } if(r < n) { ++r; if(diff[r] > 0) { sms -= diff[r]; } else { smt -= abs(diff[r]); } diff[r] -= x; if(diff[r] > 0) { sms += diff[r]; } else { smt += abs(diff[r]); } } cout<<-(sms*s-(smt*t))<<'\n'; } }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:17:17: warning: unused variable 'j' [-Wunused-variable]
   17 |     long long i,j;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...