Submission #945004

# Submission time Handle Problem Language Result Execution time Memory
945004 2024-03-13T09:49:47 Z akqxolotl Fancy Fence (CEOI20_fancyfence) C++17
0 / 100
148 ms 262144 KB
#include <bits/stdc++.h>
//#define int long long
using namespace std;
 
 
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	
	int n;cin>>n;
	vector<pair<int,int>> v;
	int h=0,w=0,wt=0;
	int hh[n],ww[n];
	for(int i=0;i<n;i++){cin>>hh[i];}
	for(int i=0;i<n;i++)cin>>ww[i];
	
	
	
	for(int j=0;j<n;j++){
		h=hh[j];
		w=ww[j];
		if(h==2){
			if(!v.empty()){
				if(v.back().second==wt){
				int temp=v.back().first;
				v.pop_back();
				v.push_back({temp,wt+w});}
				else v.push_back({wt,wt+w});
			}
			else{
				v.push_back({wt,wt+w});
			}
		}
		wt+=w;
	}
	int f[wt+1];
	f[0]=0;
	for(int i=1;i<=wt;i++){
		f[i]=f[i-1]+i;
	}
	int ans=f[wt];
	for(auto i:v){
		
		int t=i.second-i.first;
		ans+=f[t]*2;
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 129 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 148 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 134 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 134 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Runtime error 125 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 129 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -