# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1023634 | vjudge1 | Just Long Neckties (JOI20_ho_t1) | C++17 | 0 ms | 344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> calculate_minimal_strangeness(int N, vector<int>& A, vector<int>& B) {
sort(A.begin(), A.end());
vector<int> C(N + 1);
for (int i = 0; i <= N; ++i) {
int director_tie = A[i];
vector<int> other_ties;
for (int j = 0; j <= N; ++j) {
if (j != i) other_ties.push_back(A[j]);
}
int max_strangeness = 0;
for (int b : B) {
auto it = lower_bound(other_ties.begin(), other_ties.end(), b);
int best_tie = (it == other_ties.end()) ? other_ties.back() : *it;
if (it != other_ties.begin() && (abs(*(it - 1) - b) < abs(best_tie - b))) {
best_tie = *(it - 1);
}
int strangeness = max(best_tie - b, 0);
max_strangeness = max(max_strangeness, strangeness);
}
C[i] = max_strangeness;
}
return C;
}
int main() {
int N;
cin >> N;
vector<int> A(N + 1);
for (int i = 0; i <= N; ++i) {
cin >> A[i];
}
vector<int> B(N);
for (int i = 0; i < N; ++i) {
cin >> B[i];
}
vector<int> result = calculate_minimal_strangeness(N, A, B);
for (int i = 0; i <= N; ++i) {
cout << result[i] << " ";
}
cout << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |