답안 #628775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
628775 2022-08-13T16:53:15 Z Iwanttobreakfree Fancy Fence (CEOI20_fancyfence) C++17
12 / 100
7 ms 324 KB
#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;
const int mod=1e9+7;
#define int long long
signed main(){
    int n;
    cin>>n;
    vector<int> v(n),h(n),pre(n+1);
    map<int,int> mp;
    for(int& i:h)cin>>i;
    for(int& i:v)cin>>i;
    for(int i=0;i<n;i++)pre[i+1]=pre[i]+v[i];
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=(((v[i]*(v[i]+1)/2)%mod)*(h[i]*(h[i]+1)/2)%mod)%mod;
        ans%=mod;
        int he=h[i];
        for(int j=i+1;j<n;j++){
            he=min(he,h[j]);
            ans+=(((pre[j+1]-pre[j])%mod)*(he*(he+1)/2)%mod)%mod;
            ans%=mod;
            //cout<<ans<<' ';
        }
        //cout<<ans<<'\n';
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 5 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 4 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 7 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 4 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 5 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -