| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 833240 | vjudge1 | Exam (eJOI20_exam) | C++17 | 1 ms | 724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define For(i, n) for (int i = 0; i < n; i++)
#define Each(x, v) for (auto x : v)
#define pb push_back
const int MAXN = 200;
int N, H[MAXN + 5], T[MAXN + 5], dp[MAXN + 5][MAXN + 5];
int f(int l, int r) {
if (l > r) return 0;
if (l == r) {
if (T[l] == H[l]) return 1;
return 0;
}
if (dp[l][r] != -1) return dp[l][r];
int terbesar = 0, cnt = 0;
for (int i = l; i <= r; i++) terbesar = max(terbesar, H[i]);
for (int i = l; i <= r; i++) {
if (T[i] == terbesar) {
cnt++;
}
}
int ans = cnt;
for (int i = l; i <= r - 1; i++) {
ans = max(ans, f(l, i) + f(i + 1, r));
}
return dp[l][r] = ans;
}
bool ceksubsoal2() {
int pivot = T[0];
for (int i = 1; i < N; i++) {
if (T[i] != T[0]) {
return false;
}
}
return true;
}
void subsoal2() {
int target = T[0], ans = 0;
vector <int> pos;
for (int i = 0; i < N; i++) {
if (H[i] == target) {
pos.pb(i);
ans++;
}
}
Each (x, pos) {
for (int i = x - 1; i >= 0; i--) {
if (H[i] < H[x]) {
ans++;
}
}
for (int i = x + 1; i < N; i++) {
if (H[i] < H[x]) {
ans++;
}
}
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
memset(dp, -1, sizeof dp);
cin >> N;
For (i, N) cin >> H[i];
For (i, N) cin >> T[i];
if (ceksubsoal2()) subsoal2();
else cout << f(0, N - 1) << endl;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
