Submission #745851

# Submission time Handle Problem Language Result Execution time Memory
745851 2023-05-21T08:47:58 Z vjudge1 Fancy Fence (CEOI20_fancyfence) C++17
30 / 100
27 ms 3916 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll solve_rect(ll h, ll w) {
  h %= mod;
  w %= mod;
  ll hc = (h * (h + 1) / 2) % mod;
  ll wc = (w * (w + 1) / 2) % mod;
  return (hc * wc) % mod;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<ll> hv(n), wv(n);
  for (ll& h : hv) cin >> h;
  ll w_rem = 0;
  for (ll& w : wv) {
    cin >> w;
    w_rem += w;
    w_rem %= mod;
  }
  ll res = 0ll;
  ll h_prev = 0ll;
  for (int i = 0; i < n; i++) {
    int h = hv[i], w = wv[i];
    res += solve_rect(h, w_rem);
    res %= mod;
    res -= solve_rect(h_prev, w_rem);
    res += mod;
    res %= mod;
    w_rem += mod;
    w_rem -= w;
    h_prev = h;
  }
  cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 14 ms 1112 KB Output is correct
4 Correct 21 ms 1904 KB Output is correct
5 Correct 23 ms 1876 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 12 ms 1996 KB Output is correct
5 Correct 21 ms 3784 KB Output is correct
6 Correct 27 ms 3916 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 12 ms 1996 KB Output is correct
10 Correct 22 ms 3672 KB Output is correct
11 Correct 21 ms 3800 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -