제출 #566924

#제출 시각아이디문제언어결과실행 시간메모리
5669241zaid1Just Long Neckties (JOI20_ho_t1)C++14
1 / 100
1093 ms300 KiB
#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) 메시지

ho_t1.cpp: In function 'long long int check(std::vector<long long int>&, std::vector<long long int>&)':
ho_t1.cpp:13:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for (int i = 0; i < a.size(); i++) {
      |                         ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...