Submission #1051405

#TimeUsernameProblemLanguageResultExecution timeMemory
1051405NeroZeinFlooding Wall (BOI24_wall)C++17
8 / 100
248 ms456 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define debug(...) #endif const int md = (int) 1e9 + 7; void add(int& x, int y) { x += y; if (x >= md) { x -= md; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); 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 water = 0; for (int mask = 0; mask < (1 << n); ++mask) { vector<int> c(n); for (int i = 0; i < n; ++i) { c[i] = (mask >> i & 1 ? b[i] : a[i]); } vector<int> d(n); for (int i = 0; i < n; ++i) { int mxL = *max_element(c.begin(), c.begin() + i + 1); int mxR = *max_element(c.begin() + i, c.end()); d[i] = min(mxL, mxR); add(water, d[i] - c[i]); } } cout << water << '\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...