QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#465832#3872. Gym BadgesjdkjrejvmCompile Error//C111.2kb2024-07-07 10:47:522024-07-07 10:47:53

Judging History

This is the latest submission verdict.

  • [2024-07-07 10:47:53]
  • Judged
  • [2024-07-07 10:47:52]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 500010;
int X[N], L[N];

class FastScanner {
public:
    FastScanner() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }

    int nextInt() {
        int x;
        cin >> x;
        return x;
    }
};

int main() {
    FastScanner f;
    int n = f.nextInt();
    priority_queue<int> q;
    vector<array<int, 3>> tr;
    for (int i = 1; i <= n; ++i) X[i] = f.nextInt();
    for (int i = 1; i <= n; ++i) L[i] = f.nextInt();
    for (int i = 1; i <= n; ++i) tr.push_back({X[i] + L[i], X[i], L[i]});
    sort(tr.begin(), tr.end());
    
    long long sum = 0, ans = 0;
    for (int i = 1; i <= n; ++i) {
        auto &c = tr[i - 1];
        int X1 = c[1], L1 = c[2];
        if (sum <= L1) {
            sum += X1;
            q.push(X1);
            ++ans;
        } else {
            if (!q.empty() && q.top() > X1) {
                sum -= q.top();
                q.pop();
                sum += X1;
                q.push(X1);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Details

answer.code:1:10: fatal error: iostream: No such file or directory
 #include <iostream>
          ^~~~~~~~~~
compilation terminated.