#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
int mod=1e9+7;
int MOD(int x) {
return (x+mod)%mod;
}
int clc(int x, int y) {
x=MOD(x);
y=MOD(y);
return (((((x*(x+1)))/(long long)2)%mod)*((((y*(y+1)))/(long long)2)%mod))%mod; //non cest bon
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
vector<int> h(n+1);
vector<int> w(n+1);
int totalw=0;
for (int i = 1; i <= n; i++) cin>>h[i];
for (int i = 1; i <= n; i++) { cin >> w[i]; totalw=(totalw+w[i])%mod; }
int outp=0;
h[0]=0;
for (int i = 1; i <= n; i++)
{
// la formule elle marche je suis sur
// non non juste 5 oui ou 4 sur cms
//repete
int side1=clc(totalw,h[i])-clc(totalw,h[i-1]);
side1=MOD(side1); //
outp=MOD(outp+side1); //jai pas compris
totalw-=w[i];
}
cout << outp << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
11 ms |
1260 KB |
Output is correct |
4 |
Correct |
22 ms |
1884 KB |
Output is correct |
5 |
Correct |
22 ms |
1884 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
612 KB |
Output is correct |
4 |
Correct |
11 ms |
1116 KB |
Output is correct |
5 |
Correct |
23 ms |
1884 KB |
Output is correct |
6 |
Correct |
22 ms |
1884 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
612 KB |
Output is correct |
9 |
Correct |
11 ms |
1112 KB |
Output is correct |
10 |
Correct |
22 ms |
1880 KB |
Output is correct |
11 |
Correct |
28 ms |
1880 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |