답안 #900674

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900674 2024-01-08T20:42:32 Z karamkallasi Fancy Fence (CEOI20_fancyfence) C++14
0 / 100
18 ms 52056 KB
#include <bits/stdc++.h>
#define T ll tt ; cin>>tt ; while(tt--)
#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define endl '\n'
#define yes void (cout << "YES" << endl)
#define no void (cout << "NO" << endl)
#define pb push_back
#define F first
#define S second
#define ld long double
#define fixed(g) fixed<<setprecision(g)
#define ll long long
using namespace std;
const ll N = 2e6 + 9 ;
const ll oo = 1e9 + 7 ;
ll n , m , k , x , y , z , g , ans , sum , sum2 , cnt , dis[N] ,  sz , mn , a[N] , b[N] ;
bool ff , vis[N] ;
queue<pair<ll , ll> >q;
set<pair<ll , ll> >st;
vector<pair<ll , ll> >v[N] ;
int main(){
fast
    cin >> n ;
    for(ll i=0 ; i<n ; i++)cin >> a[i] ;
    for(ll i=0 ; i<n ; i++){
        cin >> b[i] ;
        sum +=b[i];
        sum %=oo ;
    }
    sum%=oo;
    for(ll i=0 ; i<n ; i++){
        if(a[i]==2){
            x +=b[i] ;
            x %= oo ;
        }
        else {
            x%=oo;
            g =  ( x * (x+1) ) ;
            g%=oo;
            ans += g ;
            ans %= oo;
            x = 0 ;
        }
    }
        x%=oo;
        g = ( x * (x+1) );
        g%=oo;
        ans += g ;
        ans %= oo;

    g = ( sum * (sum+1) ) ;
    g%=oo;
    g /= 2 ;
    g%=oo;
    g+=ans ;
    g%=oo;
    cout << g << endl ;
return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 51804 KB Output is correct
2 Incorrect 11 ms 52056 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 51804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 51936 KB Output is correct
2 Incorrect 11 ms 51804 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 51800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 51804 KB Output is correct
2 Incorrect 11 ms 51804 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 51804 KB Output is correct
2 Incorrect 11 ms 51804 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 51804 KB Output is correct
2 Incorrect 11 ms 52056 KB Output isn't correct
3 Halted 0 ms 0 KB -