제출 #1164197

#제출 시각아이디문제언어결과실행 시간메모리
1164197cjtsaiFire (BOI24_fire)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define pb push_back #define all(x) x.begin(),x.end() #define ff first #define ss second const int mod=1e9+7; signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); int n;cin>>n; vector<int> a(n), b(n); for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<n; i++) cin>>b[i]; int ans=0; for(int i=0; i<(1ll<<n); i++){ vector<int> v(n); for(int j=0; j<n; j++){ if((1ll<<j)&i) v[j]=a[j]; else v[j]=b[j]; } int tmp=0; vector<int> hl(n), hr(n); for(int j=0; j<n; j++){ tmp=max(tmp, v[j]); hl[j]=tmp; } tmp=0; for(int j=n-1; j>=0; j--){ tmp=max(tmp, v[j]); hr[j]=tmp; } int tans=0; //for(int j=0; j<n; j++) cout<<hl[j]<<'/'<<hr[j]<<' '; //cout<<'\n'; for(int j=0; j<n; j++){ tans+=min(hl[j], hr[j])-v[j]; tans%=mod; } //cout<<tans<<' '; ans+=tans; ans%=mod; } 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...