답안 #746023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
746023 2023-05-21T10:39:05 Z vjudge1 Fancy Fence (CEOI20_fancyfence) C++17
30 / 100
143 ms 2300 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int mod=1000000007;


int binpow(int a, int b){
	int ans = 1;
	while(b != 0){
		if(b % 2 == 1){
			ans=(ans*a)%mod;
		}
		a=(a*a) % mod;
		b/=2;
	}
	return ans;
}

int f(int wossz, int hossz){
	//return (((((hossz*(hossz+1)/2)%mod) * wossz)%mod)*(wossz+1)/2)%mod;
	return (((((hossz*(hossz+1)%mod*binpow(2, mod-2))%mod) * wossz)%mod)*(wossz+1)%mod*binpow(2, mod-2)%mod)%mod;
}

int32_t main() {
	// all hi are equal --> téglalap
	int s;
	cin>>s;
	int h[s];
	int w[s];
	int wossz = 0;
	bool teglalap = true;
	for (int i=0; i<s; i++){
		cin >> h[i];
		if (h[i] != h[0]) teglalap = false;
	}
	int hossz = h[0];
	for(int i=0; i<s; i++){
		cin>>w[i];
		wossz = (w[i] + wossz) % mod;
	}
	
	if (teglalap){
		cout << f(wossz, hossz);
		return 0;
	}
	
	// --------------- lépcső -----------------
	int ans = f(wossz, h[0]);
	wossz = (wossz - w[0])%mod;
	for (int i=1; i<s; i++){
		ans = (ans + f((wossz+mod)%mod, h[i]))%mod;
		ans =  (ans - f((wossz+mod)%mod, h[i-1]))%mod;
		wossz = (wossz - w[i])%mod; 
	}
	ans=(ans+mod)%mod;
	cout << ans<<"\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 8 ms 468 KB Output is correct
3 Correct 39 ms 1496 KB Output is correct
4 Correct 83 ms 2300 KB Output is correct
5 Correct 75 ms 2300 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 10 ms 580 KB Output is correct
4 Correct 38 ms 1228 KB Output is correct
5 Correct 70 ms 2092 KB Output is correct
6 Correct 82 ms 2092 KB Output is correct
7 Correct 2 ms 312 KB Output is correct
8 Correct 13 ms 580 KB Output is correct
9 Correct 65 ms 1288 KB Output is correct
10 Correct 119 ms 1972 KB Output is correct
11 Correct 143 ms 2180 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Incorrect 2 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -