Submission #691901

#TimeUsernameProblemLanguageResultExecution timeMemory
691901Paul_Liao_1457Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
129 ms13136 KiB
//記得跳題 #include<iostream> #include<array> #include<vector> #include<string> #include<algorithm> #include<set> #include<queue> #include<stack> #include<math.h> #include<map> #include<unordered_map> #include<cstring> #include<iomanip> #include<bitset> #include<tuple> #define ll long long #define int ll #define LL __int128_t #define DB double #define FOR(i,a,b) for(int i=a;i<b;i++) #define REP(i,a,b) for(ll i=a;i>=b;i--) #define pb push_back #define mp make_pair #define INF (ll)(2e9) #define MOD (ll)(1e9+7) #define F first #define S second #define endl "\n" #define AC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); /* struct func { bool operator()(const int &a, const int &b) const { return a < b; } }; */ using namespace std; template<class T> using PQ=priority_queue<T,vector<T>,greater<T> >; void file(){ freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin); freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout); } ll dis[200005],a[200005]; signed main(){ AC; ll n,q,s,t,c1=0,c2=0; cin>>n>>q>>s>>t; FOR(i,0,n+1){ cin>>a[i]; if(i){ dis[i]=a[i]-a[i-1]; if(dis[i]>0) c1+=dis[i]; else c2+=dis[i]; } } //cout<<"c1="<<c1<<" c2="<<c2<<endl; while(q--){ int l,r,x; cin>>l>>r>>x; if(dis[l]>0&&dis[l]+x<=0){ c1-=dis[l]; c2+=dis[l]+x; } else if(dis[l]<=0&&dis[l]+x>0){ c2-=dis[l]; c1+=dis[l]+x; } else{ if(dis[l]>0) c1+=x; else c2+=x; } if(r+1<=n){ if(dis[r+1]>0&&dis[r+1]-x<=0){ c1-=dis[r+1]; c2+=dis[r+1]-x; } else if(dis[r+1]<=0&&dis[r+1]-x>0){ c1+=dis[r+1]-x; c2-=dis[r+1]; } else{ if(dis[r+1]>0) c1-=x; else c2-=x; } } dis[l]+=x; dis[r+1]-=x; cout<<-(s*c1+t*c2)<<endl; } } /* 4 5 1 2 4 4 1 3 2 1 4 3 1 2 4 1 6 1 2 4 2 5 */

Compilation message (stderr)

foehn_phenomena.cpp: In function 'void file()':
foehn_phenomena.cpp:50:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:51:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...