Submission #129363

#TimeUsernameProblemLanguageResultExecution timeMemory
129363LittleFlowers__Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
137 ms7800 KiB
#include <bits/stdc++.h> using namespace std; #define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;}) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r){return l+rng()%(r-l+1);} #define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr); #define task "Foehn" #define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a) #define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a) #define forv(a,b) for(auto&a:b) #define gg exit(0) #define fi first #define se second #define pb push_back #define ii pair<int,int> #define mt make_tuple #define all(a) a.begin(),a.end() #define reset(f, x) memset(f, x, sizeof(f)) #define bit(x,i) ((x>>(i-1))&1) #define on(x,i) (x|(1ll<<(i-1))) #define off(x,i) (x&~(1<<(i-1))) main(){ //freopen(task".inp","r",stdin); //freopen(task".out","w",stdout); #define int long long int n=in,q=in,s=in,t=in,tmp=0; vector<int> a(n+1),b(n+1); forinc(i,0,n) a[i]=in; auto eval=[&](int i){ return i<0 ? i*s : i*t; }; forinc(i,1,n){ b[i]=a[i-1]-a[i]; tmp+=eval(b[i]); } forinc(i,1,q){ int l=in,r=in,x=in; if(l){ tmp-=eval(b[l]); b[l]-=x; tmp+=eval(b[l]); } if(r<n){ tmp-=eval(b[r+1]); b[r+1]+=x; tmp+=eval(b[r+1]); } cout<<tmp<<"\n"; } }

Compilation message (stderr)

foehn_phenomena.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...