# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745928 | vjudge1 | Fancy Fence (CEOI20_fancyfence) | C++17 | 2 ms | 284 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
int x, e, hossz;
int ans = 0;
vector<int> w, h;
int wsum = 0;
for(int i = 0; i < n; i++){
cin >> x;
h.push_back(x);
}
for(int i = 0; i < n; i++){
cin >> x;
wsum += x;
w.push_back(x);
}
hossz = (h[0]-1)*w[0];
for(int i = 1; i < n; i++){
if(h[i] == 2){
hossz += w[i];
}
else if(h[i-1] == 2){
// cout << hossz << " ";
ans += hossz*(hossz+1);
ans = ans % 1000000007;
hossz = 0;
}
}
// cout << hossz << " ";
ans += hossz*(hossz+1);
ans = ans % 1000000007;
ans += wsum*(wsum+1)/2;
ans = ans % 1000000007;
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |