Submission #342684

# Submission time Handle Problem Language Result Execution time Memory
342684 2021-01-02T16:10:36 Z blue Just Long Neckties (JOI20_ho_t1) C++11
Compilation error
0 ms 0 KB
#include <iostream>
#include <set>
using namespace std;

int main()
{
    int N;
    cin >> N;

    int A[N+1];
    for(int i = 0; i < N+1; i++) cin >> A[i];
    sort(A, A+N+1);

    int B[N];
    for(int i = 0; i < N; i++) cin >> B[i];
    sort(B, B+N);

    multiset<int> strange;
    for(int i = 0; i < N; i++) strange.insert(max(A[i] - B[i], 0));

    int res[N+1];

    res[N] = *strange.rbegin();

    for(int i = N-1; i >= 0; i--)
    {
        strange.erase(strange.find(max(A[i] - B[i], 0)));
        strange.insert(max(A[i+1] - B[i], 0));

        res[i] = *strange.rbegin();
    }
    for(int i = 0; i < N+1; i++) cout << res[i] << ' ';
    cout << '\n';
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:12:5: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   12 |     sort(A, A+N+1);
      |     ^~~~
      |     qsort