제출 #1062075

#제출 시각아이디문제언어결과실행 시간메모리
1062075Jarif_RahmanFlooding Wall (BOI24_wall)C++17
8 / 100
245 ms428 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; const ll md = 1e9+7; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<ll> A(n), B(n); for(ll &x: A) cin >> x; for(ll &x: B) cin >> x; ll ans = 0; for(int k = 0; k < (1<<n); k++){ vector<ll> C(n); ll cur = 0; for(int i = 0; i < n; i++){ if(k&(1<<i)) C[i] = B[i]; else C[i] = A[i]; cur-=C[i], cur%=md; } vector<ll> suff(n, 0); for(int i = n-1; i >= 0; i--){ if(i+1 < n) suff[i] = suff[i+1]; suff[i] = max(suff[i], C[i]); } ll mx = 0; for(int i = 0; i < n; i++){ mx = max(mx, C[i]); cur+=min(mx, suff[i]), cur%=md; } if(cur < 0) cur+=md; ans+=cur; ans%=md; } cout << ans << "\n"; }
#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...