Submission #731438

# Submission time Handle Problem Language Result Execution time Memory
731438 2023-04-27T12:43:24 Z eneskav Pod starim krovovima (COCI20_psk) C++17
Compilation error
0 ms 0 KB
#include <iostream>
using namespace std;
bool sorter(pair<int, int> a, pair<int, int> b)
{
    return a.second > b.second;
}
bool sorter2(pair<int, int> a, pair<int, int> b)
{
    return a.first < b.first;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    pair<int, int> a[n];
    int val[n];
    int t = 0;
    for (int i = 0; i < n; ++i)
    {
        a[i].first = i;
        int x;
        cin >> x;
        t += x;
        cin >> a[i].second;
        val[i] = 0;
    }
    sort(a, a + n, sorter);
    int ans = n;
    for (int i = 0; i < n; ++i)
    {
        if (t <= 0)
            break;
        int diff = min(t, a[i].second);
        t -= diff;
        ans--;
        val[a[i].first] = diff;
    }
    cout << ans << endl;
    for (int i = 0; i < n; ++i)
    {
        cout << val[i] << " ";
    }
    return 0;
}

Compilation message

psk.cpp: In function 'int main()':
psk.cpp:30:5: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   30 |     sort(a, a + n, sorter);
      |     ^~~~
      |     qsort