답안 #674735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674735 2022-12-26T05:19:22 Z faribourz Fancy Fence (CEOI20_fancyfence) C++14
0 / 100
1 ms 340 KB
// Only GOD
// believe in yourself
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define bit(x, y) ((x >> y)&1)
#define sz(x) (int)x.size()
#define kill(x) return cout << x << '\n', void()
#define KILL(x) return cout << x << '\n', 0
#define int ll 
const int N = 2e5+10;
const int INF = 1e9;
const int MOD = 1e9+7;
int mul(int a, int b){
	a %= MOD;
	b %= MOD;
	return (a*b)%MOD;
}
int add(int a, int b){
	return (a+b+MOD)%MOD;
}
int dp[N], h[N], w[N];
int f(int n){
	return (n*(n+1)/2)%MOD;
}
int32_t main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	for(int i = 1; i <= n;i++)
		cin >> w[i];
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int x = dp[i-1] + f(h[i]);
		int t = (2*x+(w[i]-1)*f(h[i]));
		if(t % 2 == 0){
			t /= 2;
		}
		else{
			w[i] /= 2;
		}
		int res = mul(t, w[i]);
		dp[i] = res;
		ans = add(ans, dp[i]);
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 316 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 212 KB Output is correct
2 Incorrect 1 ms 312 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -