답안 #1069119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069119 2024-08-21T16:08:03 Z Andrey Fancy Fence (CEOI20_fancyfence) C++14
100 / 100
62 ms 10440 KB
#include<bits/stdc++.h>
using namespace std;

const long long MOD = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,ans = 0;
    cin >> n;
    vector<long long> haha(n+1);
    vector<long long> bruh(n+1);
    for(long long i = 1; i <= n; i++) {
        cin >> haha[i];
    }
    for(long long i = 1; i <= n; i++) {
        cin >> bruh[i];
        bruh[i]+=bruh[i-1];
    }
    vector<pair<long long,long long>> wut(0);
    for(long long i = 1; i <= n; i++) {
        wut.push_back({haha[i],i});
    }
    sort(wut.begin(),wut.end());
    set<long long> idk;
    idk.insert(0);
    idk.insert(n+1);
    for(long long i = 0; i < n; i++) {
        long long p = wut[i].second,h = wut[i].first;
        long long r = *idk.lower_bound(p);
        long long l = *(--idk.upper_bound(p));
        idk.insert(p);
        long long x = (bruh[r-1]-bruh[l])%MOD,y = (bruh[r-1]-bruh[p])%MOD,z = (bruh[p-1]-bruh[l])%MOD;
        ans+=((x*(x+1)/2-y*(y+1)/2-z*(z+1)/2+MOD*MOD*2)%MOD)*((h*(h+1)/2)%MOD);
        ans%=MOD;
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 23 ms 4308 KB Output is correct
4 Correct 52 ms 8140 KB Output is correct
5 Correct 39 ms 8136 KB Output is correct
6 Correct 37 ms 8148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 3 ms 1240 KB Output is correct
3 Correct 21 ms 4196 KB Output is correct
4 Correct 47 ms 8136 KB Output is correct
5 Correct 46 ms 8140 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 4 ms 1240 KB Output is correct
4 Correct 22 ms 4308 KB Output is correct
5 Correct 46 ms 8140 KB Output is correct
6 Correct 47 ms 8232 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 1248 KB Output is correct
9 Correct 27 ms 4300 KB Output is correct
10 Correct 46 ms 9932 KB Output is correct
11 Correct 46 ms 10440 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 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 1 ms 348 KB Output is correct
11 Correct 21 ms 4288 KB Output is correct
12 Correct 44 ms 8136 KB Output is correct
13 Correct 44 ms 8284 KB Output is correct
14 Correct 37 ms 8136 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 4 ms 1240 KB Output is correct
17 Correct 24 ms 4300 KB Output is correct
18 Correct 48 ms 8252 KB Output is correct
19 Correct 49 ms 8048 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 3 ms 1240 KB Output is correct
22 Correct 21 ms 4320 KB Output is correct
23 Correct 55 ms 9928 KB Output is correct
24 Correct 48 ms 10188 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 5 ms 1240 KB Output is correct
31 Correct 5 ms 1300 KB Output is correct
32 Correct 26 ms 5240 KB Output is correct
33 Correct 27 ms 5268 KB Output is correct
34 Correct 59 ms 9928 KB Output is correct
35 Correct 53 ms 9836 KB Output is correct
36 Correct 59 ms 10168 KB Output is correct
37 Correct 62 ms 10184 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 58 ms 10232 KB Output is correct
40 Correct 51 ms 10184 KB Output is correct
41 Correct 41 ms 10184 KB Output is correct
42 Correct 51 ms 10036 KB Output is correct