Submission #305787

#TimeUsernameProblemLanguageResultExecution timeMemory
305787couplefireFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
222 ms12428 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("a.in", "r", stdin); 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]); } // printf("%lld \n", ans); 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); } }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%d%d%lld%lld",&num,&query,&s1,&s2);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   scanf("%d",&z);
      |   ~~~~~^~~~~~~~~
foehn_phenomena.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   35 |   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...