Submission #567205

#TimeUsernameProblemLanguageResultExecution timeMemory
5672051zaid1Just Long Neckties (JOI20_ho_t1)C++14
1 / 100
1083 ms320 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; vector<int> a, b; int check() { sort(b.begin(), b.end()); sort(a.begin(), a.end()); int ans = 0; for (int i = 0; i < a.size(); i++) { int x, y, mx = 0; x = 0, y = 0; for (int j = 0; j < i; j++) { if (max(max(a[i]-b[i], 0ll), max(a[j]-b[j], 0ll)) <= max(max(a[i]-b[j], 0ll), max(a[j]-b[i], 0ll))) continue; if (max(max(a[i]-b[i], 0ll), max(a[j]-b[j], 0ll))-max(max(a[i]-b[j], 0ll), max(a[j]-b[i], 0ll)) > mx) { x = i; y = j; mx = max(max(a[i]-b[i], 0ll), max(a[j]-b[j], 0ll))-max(max(a[i]-b[j], 0ll), max(a[j]-b[i], 0ll)); } } swap(b[x], b[y]); } for (int i = 0; i < a.size(); i++) ans = max(ans, max(a[i]-b[i], 0ll)); return ans; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); srand(time(0)); int n; cin >> n; a = vector<int>(n+1); b.resize(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(); swap(a, tmp); cout << check() << ' '; swap(a, tmp); } cout << endl; return 0; } /* 3 4 3 7 6 2 6 4 5 4 7 9 10 11 12 3 5 7 9 11 */

Compilation message (stderr)

ho_t1.cpp: In function 'long long int check()':
ho_t1.cpp:12:23: 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]
   12 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
ho_t1.cpp:27:23: 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]
   27 |     for (int i = 0; i < a.size(); i++) ans = max(ans, max(a[i]-b[i], 0ll));
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...