# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
566924 | 1zaid1 | Just Long Neckties (JOI20_ho_t1) | C++14 | 1093 ms | 300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
typedef long long ll;
const int M = 1e5 + 5, MOD = 1e9+7;
int check(vector<int>&a, vector<int>&b) {
sort(a.begin(), a.end());
int ans = INT_MAX;
do {
int cur = 0;
for (int i = 0; i < a.size(); i++) {
cur = max(cur, max(a[i]-b[i], 0ll));
} ans = min(ans, cur);
} while (next_permutation(a.begin(), a.end()));
return ans;
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
srand(time(0));
int n;
cin >> n;
vector<int> a(n+1), b(n);
for (int&i:a) cin >> i;
for (int&i:b) cin >> i;
for (int i = 0; i <= n; i++) {
auto tmp = a;
swap(tmp[i], tmp[n]);
tmp.pop_back();
cout << check(tmp, b) << ' ';
} cout << endl;
return 0;
}
/*
3
4 3 7 6
2 6 4
5
4 7 9 10 11 12
3 5 7 9 11
*/
컴파일 시 표준 에러 (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... |