제출 #153886

#제출 시각아이디문제언어결과실행 시간메모리
153886mhy908Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
193 ms13124 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define mp make_pair #define llinf 8987654321987654321 #define inf 1987654321 using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; int n, q; LL s, t; LL arr[200010], diff[200010]; LL num; int main() { scanf("%d%d%lld%lld", &n, &q, &s, &t); for(int i=0; i<=n; i++){ scanf("%lld", &arr[i]); } for(int i=0; i<n; i++){ if(arr[i]<arr[i+1])num-=s*(arr[i+1]-arr[i]); else num-=t*(arr[i+1]-arr[i]); diff[i]=arr[i+1]-arr[i]; } for(int i=1; i<=q; i++){ int a, b; LL c; scanf("%d %d %lld", &a, &b, &c); num+=diff[a-1]>0?diff[a-1]*s:diff[a-1]*t; diff[a-1]+=c; num-=diff[a-1]>0?diff[a-1]*s:diff[a-1]*t; if(b!=n){ num+=diff[b]>0?diff[b]*s:diff[b]*t; diff[b]-=c; num-=diff[b]>0?diff[b]*s:diff[b]*t; } printf("%lld\n", num); } }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:18:10: 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:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %lld", &a, &b, &c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...