Submission #945001

#TimeUsernameProblemLanguageResultExecution timeMemory
945001akqxolotlFancy Fence (CEOI20_fancyfence)C++17
0 / 100
135 ms262144 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...