답안 #901490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901490 2024-01-09T13:12:51 Z karamkallasi Fancy Fence (CEOI20_fancyfence) C++14
15 / 100
26 ms 53992 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 , gg , ans , sum , sum2 , cnt , dis[N] ,  sz , mn , a[N] , b[N] , last ;
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];
    }
    a[n] = -1 , b[n] = -1 , last = 0 ;
    for(ll i=0 ; i<n ; i++){
        if(a[i]==a[i+1]){
            x +=b[i] ;
        }
        else {
        //  cout<<sum<<' '<<x<<' '<<a[i]<<endl;
            x +=b[i] ;
            x %=oo;

            y = (sum%oo) * ((sum+1)%oo);
            z = a[i]*(a[i]+1);
            g = y ;
            gg = last*(last+1) ;

            y/=2;//6
            z/=2;//3
            g/=2;//6
            gg/=2;//1

            y%=oo;
            z%=oo;

            ans += z * y ;
            ans -= g * gg;
            ans%=oo;

            sum -= x ;

            x = 0 , y = 0 , z = 0 , g=0 , gg=0;
            last = a[i];
        }
    }
    cout << ans << endl ;
return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 51800 KB Output is correct
2 Incorrect 11 ms 51800 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 51800 KB Output isn't correct
2 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 11 ms 51800 KB Output is correct
2 Correct 12 ms 52056 KB Output is correct
3 Correct 18 ms 51864 KB Output is correct
4 Correct 26 ms 53848 KB Output is correct
5 Correct 26 ms 53840 KB Output is correct
6 Correct 10 ms 51804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 51804 KB Output is correct
2 Correct 12 ms 51940 KB Output is correct
3 Correct 12 ms 51948 KB Output is correct
4 Correct 18 ms 51800 KB Output is correct
5 Correct 25 ms 53852 KB Output is correct
6 Correct 25 ms 53992 KB Output is correct
7 Incorrect 11 ms 51804 KB Output isn't correct
8 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 11 ms 51800 KB Output is correct
2 Incorrect 11 ms 51800 KB Output isn't correct
3 Halted 0 ms 0 KB -