답안 #921468

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921468 2024-02-03T23:02:07 Z Alebn Fancy Fence (CEOI20_fancyfence) C++14
30 / 100
75 ms 4688 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int MOD = 1e9+7, INV = 250000002;

int f(int n, int m) {
    return n * m % MOD * (n + 1) % MOD * (m + 1) % MOD * INV % MOD;
}

signed main() {
    //input and sum
    int n;
    cin >> n;
    vector<int> h(n), w(n), suffixWSum(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < n; i++) cin >> w[i];
    for(int i = n-1; i > -1; i--) suffixWSum[i] = (w[i] + (i == n-1 ? 0 : suffixWSum[i+1])) % MOD;
    //linearily go over and compute result
    int res = 0, m = suffixWSum[0], pastH = 0;
    for(int i = 0; i < n; i++) {
        if(i != 0 && h[i-1] < h[i]) {
            res = ((res + f(h[i-1], m)) % MOD - f(pastH, m)) % MOD;
            if(res < 0) res = (res + 10000000070000000) % MOD;
            //cout << h[i-1] << " " << m << "\n";
            m = suffixWSum[i], pastH = h[i-1];
        }
    }
    //cout << h[n-1] << " " << m << "\n";
    res = ((res + f(h[n-1], m)) % MOD - f(pastH, m)) % MOD;
    if(res < 0) res = (res + 10000000070000000) % MOD;
    cout << res << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 360 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 6 ms 588 KB Output is correct
3 Correct 45 ms 1380 KB Output is correct
4 Correct 59 ms 2648 KB Output is correct
5 Correct 66 ms 2648 KB Output is correct
6 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 6 ms 604 KB Output is correct
4 Correct 29 ms 1620 KB Output is correct
5 Correct 58 ms 2652 KB Output is correct
6 Correct 75 ms 2780 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 6 ms 860 KB Output is correct
9 Correct 36 ms 2500 KB Output is correct
10 Correct 55 ms 4436 KB Output is correct
11 Correct 58 ms 4688 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -