Submission #142624

#TimeUsernameProblemLanguageResultExecution timeMemory
142624arnold518Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
190 ms11568 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5; int N, Q; ll S, T, A[MAXN+10], U, D; int main() { int i, j; scanf("%d%d%lld%lld", &N, &Q, &S, &T); for(i=0; i<=N; i++) scanf("%lld", &A[i]); for(i=N; i>=1; i--) A[i]-=A[i-1]; for(i=1; i<=N; i++) { if(0<A[i]) U+=A[i]; else D+=A[i]; } while(Q--) { ll L, R, X; scanf("%lld%lld%lld", &L, &R, &X); if(0<A[L]) U-=A[L]; else D-=A[L]; if(R!=N) { if(0<A[R+1]) U-=A[R+1]; else D-=A[R+1]; } A[L]+=X; A[R+1]-=X; if(0<A[L]) U+=A[L]; else D+=A[L]; if(R!=N) { if(0<A[R+1]) U+=A[R+1]; else D+=A[R+1]; } //for(i=1; i<=N; i++) printf("%lld ", A[i]); printf("\n"); //printf("%lld %lld / %lld\n", U, D, -(U*S+D*T)); printf("%lld\n", -U*S-D*T); } }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:15:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
foehn_phenomena.cpp:17: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:18:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0; i<=N; i++) scanf("%lld", &A[i]);
                      ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", &L, &R, &X);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...