답안 #854593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854593 2023-09-28T06:31:01 Z cjtsai Foehn Phenomena (JOI17_foehn_phenomena) C++14
0 / 100
73 ms 5964 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n, q, s, t; cin>>n>>q>>s>>t;
	vector<int> alt(n+1);
	vector<int> pre(n+1, 0);
	for(int i=0; i<=n; i++) cin>>pre[i];
	alt[0]=0;
	int ans=0;
	for(int i=1; i<=n; i++) {alt[i]=pre[i]-pre[i-1];ans-=(alt[i]*(alt[i]>0?s:t));}//cout<<ans<<'\n';}
	//cout<<ans;
	for(int i=0; i<q; i++){
		int l, r, x;cin>>l>>r>>x;
		if((alt[l]>=0||alt[l]<=-1*x)&&x>=0){
			//cout<<'a';
			ans-=(x*(alt[l]>=0?s:t));
		}else if((alt[l]<=0||alt[l]>=x)&&x<0){
			ans-=(x*(alt[l]<=0?t:s));
			//cout<<'b';
		}else if(alt[l]<0){
			ans+=(alt[l]*t);
			ans+=((alt[l]+x)*(-1)*s);
			//cout<<"c";
		}
		else if(alt[l]>0){
			//cout<<'d';
			ans+=(alt[l]*s);
			ans+=((x-alt[l])*t);
		}
		if(r!=n){
		if((alt[r+1]>=0||alt[r+1]<=-1*x)&&x<=0){
			ans+=(x*(alt[r+1]>=0?s:t));
		}else if((alt[r+1]<=0||alt[r+1]>=x)&&x>0){
			ans+=(x*(alt[r+1]<=0?t:s));
		}else if(alt[r+1]<0){
			ans-=(alt[r+1]*t);
			ans-=((alt[r+1]+x)*(-1)*s);
		}
		else if(alt[r+1]>0){
			ans-=(alt[r+1]*s);
			ans-=((x-alt[r+1])*t);
		}
		//alt[l]+=x;
		alt[r+1]-=x;}
		alt[l]+=x;
		//for(int x:alt) cout<<x<<' ';
		cout<<ans<<'\n';
	}

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 5964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -