#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
const int MOD = 1e9 + 7;
int main(){
int n;
cin>>n;
vl visina, sirina;
for(int i = 0; i < n; i++){
ll a;
cin>>a;
visina.pb(a);
}
for(int i = 0; i < n; i++){
ll a;
cin>>a;
sirina.pb(a);
}
ll rez = 0, cur = 0, sum = 0;
for(int i = 0; i < n; i++){
sum += sirina[i];
sum %= MOD;
if(visina[i] == 2)
{
cur += sirina[i];
cur %= MOD;
}
else{
if(cur > 0){
rez += cur * (cur + 1);
rez %= MOD;
cur = 0;
}
}
}
if(cur > 0){
rez += cur * (cur + 1);
rez %= MOD;
}
rez += sum * (sum + 1) / 2;
rez %= MOD;
cout<<rez<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
30 ms |
1916 KB |
Output is correct |
4 |
Correct |
55 ms |
3616 KB |
Output is correct |
5 |
Correct |
69 ms |
3504 KB |
Output is correct |
6 |
Correct |
58 ms |
3608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |