답안 #714948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714948 2023-03-25T14:48:27 Z TheConverseEngineer 3D Histogram (COCI20_histogram) C++17
20 / 110
23 ms 1272 KB
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define sqr(x) ((ll)(x))*(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define MOD 1000000007


int N; 
int W[12][2005], H[12][2005];

int minH(int l, int r) {
	int i = __builtin_clz(1) - __builtin_clz(r-l+1);
	return min(H[i][l], H[i][r - (1<<i) + 1]);
}

int minW(int l, int r) {
	int i = __builtin_clz(1) - __builtin_clz(r-l+1);
	return min(W[i][l], W[i][r - (1<<i) + 1]);
}

int main() {
	cin.tie(0)->sync_with_stdio(0);

	cin >> N; FOR(i, 0, N) cin >> W[0][i] >> H[0][i];
	for (int i = 1; i <= 11; ++i) {
		for (int j = 0; j + (1<<i) <= N; ++j) {
			W[i][j] = min(W[i-1][j], W[i-1][j + (1<<(i-1))]);
			H[i][j] = min(H[i-1][j], H[i-1][j + (1<<(i-1))]);
		}
	}

	ll mx = 0;
	FOR(i, 0, N) {
		FOR(j, i, N) {
			mx = max(mx, (ll)minH(i, j)*minW(i, j)*(j-i+1));
			
		}
	}

	cout << mx;
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 468 KB Output is correct
2 Correct 23 ms 468 KB Output is correct
3 Correct 21 ms 584 KB Output is correct
4 Correct 18 ms 468 KB Output is correct
5 Correct 16 ms 468 KB Output is correct
6 Correct 21 ms 468 KB Output is correct
7 Correct 18 ms 512 KB Output is correct
8 Correct 18 ms 468 KB Output is correct
9 Correct 20 ms 460 KB Output is correct
10 Correct 19 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 21 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 468 KB Output is correct
2 Correct 23 ms 468 KB Output is correct
3 Correct 21 ms 584 KB Output is correct
4 Correct 18 ms 468 KB Output is correct
5 Correct 16 ms 468 KB Output is correct
6 Correct 21 ms 468 KB Output is correct
7 Correct 18 ms 512 KB Output is correct
8 Correct 18 ms 468 KB Output is correct
9 Correct 20 ms 460 KB Output is correct
10 Correct 19 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 21 ms 532 KB Output is correct
13 Runtime error 5 ms 1272 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -