| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1341310 | LucasLe | Exhibition 3 (JOI25_exhibition3) | C++20 | 61 ms | 456 KiB |
#include <bits/stdc++.h>
const int maxn = 1000;
int N, M;
int A[maxn + 5], L[maxn + 5], R[maxn + 5], val[maxn + 5];
bool used[maxn + 5];
int ans[maxn + 5];
bool check(std::string &x, std::string &y) {
if (y.empty()) return false;
if (x.empty()) {
x = y;
return true;
}
if (x.size() >= y.size()) {
for (int i = 0; i < y.size(); ++i) {
if (x[i] != y[i]) {
if (x[i] > y[i]) {
x = y;
return true;
} else {
return false;
}
}
}
return false;
} else {
for (int i = 0; i < x.size(); ++i) {
if (x[i] != y[i]) {
if (x[i] > y[i]) {
x = y;
return true;
} else {
return false;
}
}
}
x = y;
return true;
}
}
int main() {
std::cin.tie(0)->sync_with_stdio(0);
std::cin >> N >> M;
for (int i = 1; i <= N; ++i) {
std::cin >> A[i];
}
std::sort(A + 1, A + N + 1, std::greater<int>());
for (int i = 1; i <= M; ++i) {
std::cin >> L[i] >> R[i];
}
for (int i = 1, rem = M; i <= N; ++i) {
if (!rem) {
for (int j = 1; j <= N; ++j) if (!ans[j]) {
ans[j] = A[i++];
}
break;
}
int pos;
std::string s;
for (int j = 1; j <= N; ++j) if (!ans[j]) {
std::string tmp;
for (int k = 1; k <= M; ++k) if (!used[k] && L[k] <= j && j <= R[k]) {
tmp.push_back(char(k + '0'));
}
if (check(s, tmp)) {
pos = j;
}
}
ans[pos] = A[i];
for (char c : s) {
used[c - '0'] = true;
val[c - '0'] = A[i];
rem--;
}
}
for (int i = 1; i <= M; ++i) {
std::cout << val[i] << " \n"[i == M];
}
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
