Submission #900676

# Submission time Handle Problem Language Result Execution time Memory
900676 2024-01-08T20:57:41 Z karamkallasi Fancy Fence (CEOI20_fancyfence) C++14
13 / 100
24 ms 55132 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] ;
vector<pair<ll , ll> >v[N] ;
int main(){
fast
    sum = 0 ;
    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 ;
    }
    for(ll i=0 ; i<n ; i++){
        if(a[i]==2){
            x +=b[i] ;
            x %=oo ;
        }
        if(a[i]==1 || i==n-1){
            x%=oo;
            g =  ( x * (x+1) ) ;
            g%=oo;
            cnt %=oo ;
            cnt += g  ;
            cnt %=oo ;
            x = 0 ;
        }
    }
    sum%=oo;
    ans = ( sum * (sum+1) ) ;
    ans /= 2 ;
    ans %=oo;

    ans +=cnt ;
    ans %=oo;
    cout << ans << endl ;
return 0 ;
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 51800 KB Output is correct
2 Incorrect 11 ms 51800 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 51940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 51800 KB Output is correct
2 Correct 11 ms 51840 KB Output is correct
3 Correct 17 ms 52316 KB Output is correct
4 Correct 24 ms 55132 KB Output is correct
5 Correct 23 ms 55120 KB Output is correct
6 Correct 22 ms 55120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 51800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 51800 KB Output is correct
2 Incorrect 10 ms 51804 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 51800 KB Output is correct
2 Incorrect 11 ms 51800 KB Output isn't correct
3 Halted 0 ms 0 KB -