제출 #1004983

#제출 시각아이디문제언어결과실행 시간메모리
1004983Trisanu_DasFlooding Wall (BOI24_wall)C++17
8 / 100
100 ms600 KiB
#include <bits/stdc++.h> using namespace std; const long long mod=1000000007; long long twok[500005]; int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; pair<long long,long long> arr[n]; for(int i=0; i<n; i++) cin >> arr[i].first; for(int i=0; i<n; i++) cin >> arr[i].second; for(int i=0; i<n; i++){ if(arr[i].first>arr[i].second)swap(arr[i].first,arr[i].second); } long long ans=0; for(int bm=0; bm<(1<<n); bm++){ long long brr[n]; for(int i=0; i<n; i++){ if(bm&(1<<i)) brr[i]=arr[i].first; else brr[i]=arr[i].second; } pair<long long,long long> mx[n]; mx[0].first=brr[0]; mx[n-1].second=brr[n-1]; for(int i=1; i<n; i++) mx[i].first=max(mx[i-1].first,brr[i]); for(int i=n-2; i>=0; i--) mx[i].second=max(mx[i+1].second,brr[i]); for(int i=0; i<n; i++) ans+=min(mx[i].first,mx[i].second)-brr[i]; } cout << ans%mod; }
#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...