제출 #36159

#제출 시각아이디문제언어결과실행 시간메모리
36159lequangtanFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
0 ms3512 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() { freopen ("WIND.INP","r",stdin); freopen ("WIND.OUT","w",stdout); 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:15:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen ("WIND.INP","r",stdin);
                                ^
foehn_phenomena.cpp:16:33: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen ("WIND.OUT","w",stdout);
                                 ^
foehn_phenomena.cpp:18:43: 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:23:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&z);
                 ^
foehn_phenomena.cpp:35:30: 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...