Submission #1167403

#TimeUsernameProblemLanguageResultExecution timeMemory
1167403henriessFancy Fence (CEOI20_fancyfence)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	long long n;cin >> n;
	vector<long long> h(n);
	vector<long long> w(n);
	for(int i = 0;i<n;i++){
		cin >> h[i];
	}
	for(int i = 0;i<n;i++){
		cin >> w[i];
	}
	
	//Subtask 1 : width is all equal to 1, that means they are all like towers 
	//formula : w(w+1)h(h+1) / 4;
	//subtask 3 : all hi are equal 
	long long totalwidth = 0;
	for(int i = 0;i<n;i++){
		totalwidth += w[i] ;
	}
	long long n1 = totalwidth * (totalwidth + 1) % MOD;
	long long n2 = h[0] *(h[0] + 1) % MOD;
	long long inv4 = 250000002;
	long long ans = ((n1 * n2) % MOD * inv4) % MOD;

	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...