# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303400 | 2020-09-20T09:37:53 Z | BeanZ | Fancy Fence (CEOI20_fancyfence) | C++14 | 35 ms | 5120 KB |
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e5 + 5; const int mod = 1e9 + 7; ll h[N], w[N], sum[N], g[N]; ll dp[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n; cin >> n; ll ans = 0; for (int i = 1; i <= n; i++) cin >> h[i]; for (int i = 1; i <= n; i++) cin >> w[i], g[i] = g[i - 1] + w[i]; h[0] = 0; stack<ll> s; s.push(0); for (int i = 1; i <= n; i++){ while (s.size()){ if (h[s.top()] > h[i]) s.pop(); else break; } dp[i] = (w[i] * (w[i] + 1) / 2) % mod * ((h[i] * (h[i] + 1) / 2) % mod) % mod; sum[i] = sum[s.top()] + (g[i - 1] - g[s.top()]) * ((h[i] * (h[i] + 1) / 2) % mod) % mod; dp[i] = (dp[i] + sum[i] * w[i]) % mod; ans = (ans + dp[i]) % mod; sum[i] = (sum[i] + ((h[i] * (h[i] + 1) / 2) % mod) * w[i] % mod) % mod; s.push(i); } cout << ans; } /* 2 2 2 2 4 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 13 ms | 2432 KB | Output is correct |
4 | Correct | 25 ms | 4864 KB | Output is correct |
5 | Correct | 25 ms | 4632 KB | Output is correct |
6 | Correct | 26 ms | 4472 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 16 ms | 2688 KB | Output is correct |
4 | Correct | 31 ms | 5112 KB | Output is correct |
5 | Correct | 33 ms | 5112 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 768 KB | Output is correct |
4 | Correct | 16 ms | 2680 KB | Output is correct |
5 | Correct | 31 ms | 5112 KB | Output is correct |
6 | Correct | 35 ms | 5112 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 4 ms | 768 KB | Output is correct |
9 | Correct | 18 ms | 2680 KB | Output is correct |
10 | Correct | 30 ms | 5120 KB | Output is correct |
11 | Correct | 31 ms | 5112 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 416 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |