제출 #197017

#제출 시각아이디문제언어결과실행 시간메모리
197017quocnguyen1012Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
183 ms6632 KiB
#include<stdio.h> #include<vector> #include<algorithm> using namespace std; typedef long long ll; ll s1,s2; ll dif[300001]; ll get(ll t) { if(t>0)return -s1*t; else return -s2*t; } int main() { int num,query; scanf("%d%d%lld%lld",&num,&query,&s1,&s2); vector<int>v; for(int i=0;i<=num;i++) { int z; scanf("%d",&z); v.push_back(z); } ll ans=0; for(int i=0;i<num;i++) { dif[i]=v[i+1]-v[i]; ans+=get(dif[i]); } for(int i=0;i<query;i++) { int za,zb,zc; scanf("%d%d%d",&za,&zb,&zc); ans-=get(dif[za-1]); dif[za-1]+=zc; ans+=get(dif[za-1]); if(zb!=num) { ans-=get(dif[zb]); dif[zb]-=zc; ans+=get(dif[zb]); } printf("%lld\n",ans); } }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%lld%lld",&num,&query,&s1,&s2);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&z);
   ~~~~~^~~~~~~~~
foehn_phenomena.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&za,&zb,&zc);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...