Submission #1234537

#TimeUsernameProblemLanguageResultExecution timeMemory
1234537Bui_Quoc_CuongJust Long Neckties (JOI20_ho_t1)C++20
9 / 100
1092 ms3716 KiB
#include <bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int)b; i--)
#define ALL(A) A.begin(), A.end()
using namespace std;
const int maxn = 200005;
int n;
int c[maxn], a[maxn];
int main(){
    cin.tie(nullptr) -> sync_with_stdio(false);
    #define taskname "kieuoanh"
    if(fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout);
    }
    cin >> n;
    FOR(i, 1, n + 1) cin >> c[i];
    FOR(i, 1, n) cin >> a[i];
    sort(a + 1, a + 1 + n);
    FOR(i, 1, n + 1){
    	int ans = 0;
    	vector <int> cur;
    	FOR(j, 1, n + 1) if(i != j) cur.push_back(c[j]);
    	sort(ALL(cur));
    	FOR(j, 1, n) ans = max(ans, max(0, cur[j - 1] - a[j]));
    	cout << ans << " ";
    }
    return 0;
}

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:14:53: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout);
      |                                              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...