답안 #963038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963038 2024-04-14T11:51:20 Z anton Fancy Fence (CEOI20_fancyfence) C++17
13 / 100
15 ms 4208 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long
#define pii pair<int,int>

const int MAX_N = 1e5+1;
const int mod =1e9+7;

int h[MAX_N];
int w[MAX_N];

int nbp(int u){
    return (u*(u+1LL)/2LL)%mod;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n; 
    cin>>n;
    int sw = 0;
    vector<pair<int, int>> ev;
    for(int i = 0; i<n; i++){
        cin>>h[i];
    }
    for(int i = 0; i<n; i++){
        cin>>w[i];
        sw = (sw+w[i])%mod;
    }

    h[n] = 0;
    w[n] = 0;

    for(int i= 0; i<=n; i++){
        if(i == 0 || h[i] != h[i-1]){
            ev.push_back({h[i], w[i]});
        }
        else{
            ev.back().second  =(ev.back().second+w[i])%mod;
        }
    }




    int res= 0;
    
    res= nbp(sw);

    for(auto e: ev){
        if(e.first == 2){
            res = (res + 2LL*nbp(e.second))%mod;
        }
    }
    cout<<res<<endl;


}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 600 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 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 7 ms 1760 KB Output is correct
4 Correct 14 ms 3700 KB Output is correct
5 Correct 15 ms 4208 KB Output is correct
6 Correct 14 ms 3744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 344 KB Output is correct
2 Incorrect 1 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -