제출 #1006648

#제출 시각아이디문제언어결과실행 시간메모리
1006648MilosMilutinovicFlooding Wall (BOI24_wall)C++14
8 / 100
325 ms596 KiB
#include <bits/stdc++.h> using namespace std; const int md = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } int res = 0; for (int mask = 0; mask < (1 << n); mask++) { vector<int> f; for (int i = 0; i < n; i++) { if (mask >> i & 1) { f.push_back(a[i]); } else { f.push_back(b[i]); } } vector<int> L(n); for (int i = 0; i < n; i++) { L[i] = max(i == 0 ? 0 : L[i - 1], f[i]); } vector<int> R(n); for (int i = n - 1; i >= 0; i--) { R[i] = max(i == n - 1 ? 0 : R[i + 1], f[i]); } for (int i = 1; i + 1 < n; i++) { res += max(0, min(L[i - 1], R[i + 1]) - f[i]); res %= md; } } cout << res << '\n'; return 0; }
#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...