제출 #404125

#제출 시각아이디문제언어결과실행 시간메모리
404125radaiosm7Foehn Phenomena (JOI17_foehn_phenomena)C++98
100 / 100
232 ms11460 KiB
#include <bits/stdc++.h> using namespace std; int n, q, i, l, r; long long s, t, c, ans, curl1, curl2, curr1, curr2; long long fen[200005]; void add(long long val, int indx) { for (; indx <= n; indx += (indx& - indx)) { fen[indx] += val; } } void addlr(long long val, int l, int r) { add(val, l); add(-val, r+1); } long long point(int indx) { long long res = 0LL; for (; indx > 0; indx -= (indx & -indx)) { res += fen[indx]; } return res; } void ansplus(int indx) { long long curr = point(indx)-point(indx-1); if (curr >= 0LL) { ans -= curr*s; } else { ans -= curr*t; } } void ansminus(int indx) { long long curr = point(indx)-point(indx-1); if (curr >= 0LL) { ans += curr*s; } else { ans += curr*t; } } int main() { scanf("%d%d%lld%lld", &n, &q, &s, &t); ans = 0LL; //t *= -1LL; scanf("%lld", &c); for (i=1; i <= n; ++i) { scanf("%lld", &c); add(c-point(i-1), i); ansplus(i); } while (q--) { scanf("%d%d%lld", &l, &r, &c); ansminus(l); if (r+1 <= n) ansminus(r+1); addlr(c, l, r); ansplus(l); if (r+1 <= n) ansplus(r+1); printf("%lld\n", ans); } return 0; }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |   scanf("%d%d%lld%lld", &n, &q, &s, &t);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:53:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |   scanf("%lld", &c);
      |   ~~~~~^~~~~~~~~~~~
foehn_phenomena.cpp:56:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |     scanf("%lld", &c);
      |     ~~~~~^~~~~~~~~~~~
foehn_phenomena.cpp:63:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |     scanf("%d%d%lld", &l, &r, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...