Submission #191329

#TimeUsernameProblemLanguageResultExecution timeMemory
191329AkashiFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
188 ms12424 KiB
#include <bits/stdc++.h> using namespace std; int n, q, s, t; int x[200005]; long long deg; long long d[200005]; int main() { scanf("%d%d%d%d", &n, &q, &s, &t); for(int i = 1; i <= n + 1 ; ++i) scanf("%d", &x[i]); for(int i = 1; i <= n ; ++i){ d[i] = x[i] - x[i + 1]; if(d[i] >= 0) deg += 1LL * t * d[i]; else deg += 1LL * s * d[i]; } int l, r, val; for(int i = 1; i <= q ; ++i){ scanf("%d%d%d", &l, &r, &val); ++l; ++r; if(l > 1){ if(d[l - 1] >= 0) deg -= 1LL * t * d[l - 1]; else deg -= 1LL * s * d[l - 1]; d[l - 1] -= val; if(d[l - 1] >= 0) deg += 1LL * t * d[l - 1]; else deg += 1LL * s * d[l - 1]; } if(r <= n){ if(d[r] >= 0) deg -= 1LL * t * d[r]; else deg -= 1LL * s * d[r]; d[r] += val; if(d[r] >= 0) deg += 1LL * t * d[r]; else deg += 1LL * s * d[r]; } printf("%lld\n", deg); } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &n, &q, &s, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:14:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n + 1 ; ++i) scanf("%d", &x[i]);
                                      ~~~~~^~~~~~~~~~~~~
foehn_phenomena.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &l, &r, &val);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...