# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1013589 | 2024-07-03T16:59:10 Z | daffuwu | Fancy Fence (CEOI20_fancyfence) | C++14 | 24 ms | 3928 KB |
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); long long n, h[100069], w, dp[100069], ans, ps[100069]; const long long dv = 1e9+7; stack<long long> stk; long long calc(long long a, long long b) { if (a%2 == 0) a/=2; else b/=2; return a%dv*(b%dv)%dv; } int main() { long long i, j; scanf("%lld", &n); for (i=1; i<=n; i++) { scanf("%lld", h+i); } stk.push(0); for (i=1; i<=n; i++) { scanf("%lld", &w); ps[i] = ps[i-1]+w; for (; h[i]<=h[stk.top()]; stk.pop()); j = stk.top(); ans += (calc(ps[i]-ps[j], ps[i]-ps[j]+1)-calc(ps[i-1]-ps[j], ps[i-1]-ps[j]+1))*calc(h[i], h[i]+1)%dv; ans += dp[j]*w%dv; ans %= dv; dp[i] = (dp[j]+calc(h[i], h[i]+1)*(ps[i]-ps[j])%dv)%dv; stk.push(i); } printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 9 ms | 2140 KB | Output is correct |
4 | Correct | 20 ms | 3904 KB | Output is correct |
5 | Correct | 16 ms | 3928 KB | Output is correct |
6 | Correct | 24 ms | 3924 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Incorrect | 1 ms | 344 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 352 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |