#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] ;
for(ll i=0 ; i<n ; i++){
sum+=b[i];
sum %= oo ;
}
for(ll i=0 ; i<n ; i++){
if(a[i]==2){
x+=b[i] ;
}
else {
g = (x%oo) * ((x+1)%oo) ;
g/=2 ;
ans+= (g%oo) ;
x = 0 ;
ff = 0 ;
}
}
if(x){
ans+= (x%oo) * ((x+1)%oo) / 2 ;
}
// cout << ans <<' '<<sum << ' ';
cout << ans + (sum%oo) * ((sum+1)%oo) /2 << endl ;
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
51804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
51844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
51804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
11 ms |
51804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
12 ms |
51804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |