제출 #173416

#제출 시각아이디문제언어결과실행 시간메모리
173416dennisstarFoehn Phenomena (JOI17_foehn_phenomena)C++11
100 / 100
676 ms23928 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ryan bear #define all(V) ((V).begin()), ((V).end()) using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef long double ld; typedef vector<int> vim; typedef vector<ll> vlm; int N, Q; ll S, T; ll A[1000010]; int L, R; ll X, now; struct dt { ll ar[(1<<22)], lz[(1<<22)]; void init() { for (int i=0; i<=N; i++) upd(i, i, A[i]); } ll get(int t, int s, int e, int i) { spread(i); if (s==e) return ar[i]; int md=(s+e)/2; if (t<=md) return get(t, s, md, i*2); else return get(t, md+1, e, i*2+1); } void upd(int is, int ie, int s, int e, int i, ll val) { if (s>e) return ; if (is<=s&&e<=ie) { lz[i]+=val; return ; } int md=(s+e)/2; if (is<=md) upd(is, ie, s, md, i*2, val); if (md+1<=ie) upd(is, ie, md+1, e, i*2+1, val); } void spread(int i) { if (i<(1<<21)) lz[i*2]+=lz[i], lz[i*2+1]+=lz[i]; ar[i]+=lz[i]; lz[i]=0; } void upd(int is, int ie, ll val) { upd(is, ie, 0, N, 1, val); } ll get(int t) { return get(t, 0, N, 1); } }DS; ll f(ll a, ll b) { return (a-b)*(a<b?S:T); } int main() { scanf("%d %d %lld %lld", &N, &Q, &S, &T); for (int i=0; i<=N; i++) scanf("%lld", &A[i]); for (int i=1; i<=N; i++) now+=f(A[i-1], A[i]); DS.init(); ll a, b; for (int i=0; i<Q; i++) { scanf("%d %d %lld", &L, &R, &X); now-=f(DS.get(L-1), DS.get(L)); if (R!=N) now-=f(DS.get(R), DS.get(R+1)); DS.upd(L, R, X); now+=f(DS.get(L-1), DS.get(L)); if (R!=N) now+=f(DS.get(R), DS.get(R+1)); printf("%lld\n", now); } return 0; }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:50:5: warning: unused variable 'a' [-Wunused-variable]
  ll a, b;
     ^
foehn_phenomena.cpp:50:8: warning: unused variable 'b' [-Wunused-variable]
  ll a, b;
        ^
foehn_phenomena.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %lld %lld", &N, &Q, &S, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:47:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0; i<=N; i++) scanf("%lld", &A[i]);
                           ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %lld", &L, &R, &X);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...