# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
311001 | 2020-10-09T03:06:09 Z | urd05 | Fancy Fence (CEOI20_fancyfence) | C++14 | 164 ms | 10216 KB |
#include <bits/stdc++.h> using namespace std; long long h[100000]; long long w[100000]; long long pos[100000]; typedef pair<int,int> P; priority_queue<P,vector<P>,greater<P>> pq; const int mod=1e9+7; long long inv2=5e8+4; int main(void) { int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%lld",&h[i]); pq.push(P(h[i]+1,i)); } set<long long> s; long long sum=0; for(int i=0;i<n;i++) { scanf("%lld",&w[i]); sum+=w[i]; if (i) { pos[i]=pos[i-1]+w[i-1]; } } s.insert(0); s.insert(sum); sum%=mod; long long pl=(sum*(sum+1)); pl%=mod; pl*=inv2; pl%=mod; long long prev=0; long long ret=0; while (!pq.empty()) { long long save=pl; int now=pq.top().first; while (!pq.empty()&&pq.top().first==now) { long long p=pos[pq.top().second]; long long d=*(--(s.upper_bound(p))); long long u=*s.lower_bound(p+w[pq.top().second]); long long len=(u-d)%mod; pl-=(((len*(len+1))%mod)*inv2)%mod; len=(p-d)%mod; pl+=(((len*(len+1))%mod)*inv2)%mod; len=(u-p-w[pq.top().second])%mod; pl+=(((len*(len+1))%mod)*inv2)%mod; pl%=mod; pl+=mod; pl%=mod; s.insert(p); s.insert(p+w[pq.top().second]); pq.pop(); } long long len=now; ret+=(save*((((len*(len+mod-1))%mod)*inv2)%mod))%mod; len=prev; ret-=(save*((((len*(len+mod-1))%mod)*inv2)%mod))%mod; ret%=mod; ret+=mod; ret%=mod; prev=now; } printf("%lld",ret); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 50 ms | 4208 KB | Output is correct |
4 | Correct | 100 ms | 8172 KB | Output is correct |
5 | Correct | 99 ms | 8168 KB | Output is correct |
6 | Correct | 88 ms | 8172 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 9 ms | 1152 KB | Output is correct |
3 | Correct | 49 ms | 4208 KB | Output is correct |
4 | Correct | 105 ms | 8168 KB | Output is correct |
5 | Correct | 103 ms | 8172 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 10 ms | 1280 KB | Output is correct |
4 | Correct | 50 ms | 5232 KB | Output is correct |
5 | Correct | 104 ms | 10116 KB | Output is correct |
6 | Correct | 104 ms | 10216 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 9 ms | 1280 KB | Output is correct |
9 | Correct | 49 ms | 5232 KB | Output is correct |
10 | Correct | 104 ms | 9992 KB | Output is correct |
11 | Correct | 104 ms | 10088 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 380 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 47 ms | 4844 KB | Output is correct |
12 | Correct | 102 ms | 9324 KB | Output is correct |
13 | Correct | 100 ms | 9448 KB | Output is correct |
14 | Correct | 88 ms | 9372 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 9 ms | 1280 KB | Output is correct |
17 | Correct | 50 ms | 5228 KB | Output is correct |
18 | Correct | 103 ms | 10088 KB | Output is correct |
19 | Correct | 102 ms | 10216 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 9 ms | 1280 KB | Output is correct |
22 | Correct | 49 ms | 5232 KB | Output is correct |
23 | Correct | 103 ms | 9960 KB | Output is correct |
24 | Correct | 103 ms | 10088 KB | Output is correct |
25 | Correct | 1 ms | 512 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 12 ms | 1408 KB | Output is correct |
31 | Correct | 12 ms | 1280 KB | Output is correct |
32 | Correct | 64 ms | 5156 KB | Output is correct |
33 | Correct | 67 ms | 5232 KB | Output is correct |
34 | Correct | 164 ms | 9832 KB | Output is correct |
35 | Correct | 134 ms | 9992 KB | Output is correct |
36 | Correct | 163 ms | 10092 KB | Output is correct |
37 | Correct | 162 ms | 10088 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 146 ms | 10108 KB | Output is correct |
40 | Correct | 124 ms | 10092 KB | Output is correct |
41 | Correct | 102 ms | 10092 KB | Output is correct |
42 | Correct | 107 ms | 10168 KB | Output is correct |