Submission #1051405

# Submission time Handle Problem Language Result Execution time Memory
1051405 2024-08-10T06:06:55 Z NeroZein Flooding Wall (BOI24_wall) C++17
8 / 100
248 ms 456 KB
#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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 229 ms 348 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 227 ms 432 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 242 ms 428 KB Output is correct
16 Correct 244 ms 344 KB Output is correct
17 Correct 248 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 23 ms 456 KB Output is correct
21 Correct 227 ms 424 KB Output is correct
22 Correct 105 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 241 ms 428 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 223 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 241 ms 428 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 223 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 229 ms 348 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 227 ms 432 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 242 ms 428 KB Output is correct
16 Correct 244 ms 344 KB Output is correct
17 Correct 248 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 23 ms 456 KB Output is correct
21 Correct 227 ms 424 KB Output is correct
22 Correct 105 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 241 ms 428 KB Output is correct
34 Correct 5 ms 348 KB Output is correct
35 Correct 223 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Incorrect 0 ms 348 KB Output isn't correct
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 237 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 229 ms 348 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 227 ms 432 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 242 ms 428 KB Output is correct
16 Correct 244 ms 344 KB Output is correct
17 Correct 248 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 23 ms 456 KB Output is correct
21 Correct 227 ms 424 KB Output is correct
22 Correct 105 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 241 ms 428 KB Output is correct
34 Correct 5 ms 348 KB Output is correct
35 Correct 223 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Incorrect 0 ms 348 KB Output isn't correct
38 Halted 0 ms 0 KB -