답안 #959874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
959874 2024-04-09T09:09:10 Z penguin133 Fancy Fence (CEOI20_fancyfence) C++17
25 / 100
19 ms 4700 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pi pair <int, int> 
#define pii pair <int, pi>

int n, H[100005], W[100005], P[100005];
stack <pi> s;
int lst[105];
const int mod = 1e9 + 7;

void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++)cin >> H[i];
	for(int i = 1; i <= n; i++)cin >> W[i];
	s.push({0, 0});
	int ans = 0;
	for(int i = 1; i <= n; i++){
		P[i] = P[i - 1] + W[i];
		P[i] %= mod;
		for(int j = H[i] + 1; j <= 100; j++)lst[j] = P[i];
		for(int j = 1; j <= H[i]; j++){
			ans += j * W[i] % mod * (P[i - 1] - lst[j] + mod) % mod;
			ans %= mod;
			int a = W[i] * (W[i] + 1) / 2;
			a %= mod;
			a *=j; a %= mod;
			ans += a; ans %= mod;
		}
		//cout << ans << '\n';
	}
	cout << ans;
}

main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int tc = 1;
	//cin >> tc;
	while(tc--)solve();
}

Compilation message

fancyfence.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 5 ms 4700 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 9 ms 3164 KB Output is correct
4 Correct 17 ms 3932 KB Output is correct
5 Correct 18 ms 3932 KB Output is correct
6 Correct 19 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 4700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Runtime error 5 ms 4700 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Runtime error 5 ms 4700 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 5 ms 4700 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -