답안 #954424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954424 2024-03-27T20:55:31 Z MinaRagy06 Fancy Fence (CEOI20_fancyfence) C++17
30 / 100
1000 ms 1400 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int mod = 1e9 + 7;
struct mint {
	int v;
	mint(ll x) {
		if (x >= mod) {
			v = x % mod;
		} else {
			v = x;
		}
	}
	mint& operator+=(const mint &b) {
		if ((v += b.v) >= mod) {
			v -= mod;
		}
		return *this;
	}
	friend mint operator+(mint a, mint b) {
		return a += b;
	}
	mint& operator*=(const mint &b) {
		v = 1ll * v * b.v % mod;
		return *this;
	}
	friend mint operator*(mint a, mint b) {
		return a *= b;
	}
	mint power(mint a, int b) {
		mint ans = 1;
		while (b) {
			if (b & 1) {
				ans *= a;
			}
			a *= a, b >>= 1;
		}
		return ans;
	}
	mint& operator/=(const mint &b) {
		v = 1ll * v * power(b, mod - 2).v % mod;
		return *this;
	}
	friend mint operator/(mint a, mint b) {
		return a /= b;
	}
	friend ostream& operator<<(ostream &os, mint a) {
		return os << a.v;
	}
	friend istream& operator>>(istream &is, mint &a) {
		return is >> a.v;
	}
};
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	int h[n], w[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	mint ans = 0;
	for (int l = 0; l < n; l++) {
		int mn = h[l];
		ans += (mint(w[l]) * (w[l] + 1) / 2) * (mint(h[l]) * (h[l] + 1) / 2);
		for (int r = l + 1; r < n; r++) {
			mn = min(mn, h[r]);
			ans += mint(w[l]) * w[r] * (mint(mn) * (mn + 1) / 2);
		}
	}
	cout << ans << '\n';
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 75 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 74 ms 348 KB Output is correct
3 Execution timed out 1008 ms 1372 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 452 KB Output is correct
2 Execution timed out 1089 ms 472 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 75 ms 348 KB Output is correct
3 Execution timed out 1052 ms 604 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 75 ms 460 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 76 ms 468 KB Output is correct
9 Correct 74 ms 344 KB Output is correct
10 Correct 74 ms 456 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 19 ms 468 KB Output is correct
13 Correct 75 ms 460 KB Output is correct
14 Correct 75 ms 456 KB Output is correct
15 Correct 75 ms 600 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 75 ms 464 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 75 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 376 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 75 ms 600 KB Output is correct
11 Execution timed out 1093 ms 1400 KB Time limit exceeded
12 Halted 0 ms 0 KB -