Submission #1078738

#TimeUsernameProblemLanguageResultExecution timeMemory
1078738_callmelucianAdvertisement 2 (JOI23_ho_t2)C++14
100 / 100
123 ms15604 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;

#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())

struct person {
    int E, X;

    person() : E(0), X(0) {}
    person (int E) : E(E), X(X) {}

    friend istream& operator >> (istream &inp, person &cur) {
        inp >> cur.X >> cur.E;
        return inp;
    }

    int sum() { return E + X; }
    int diff() { return E - X; }

    bool operator < (person o) {
        if (sum() == o.sum()) return diff() < o.diff();
        return sum() < o.sum();
    }
};

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n; cin >> n;
    vector<person> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i];
    sort(all(vec));

    vector<int> line;
    for (int i = 0; i < n; i++) {
        while (line.size() && line.back() <= vec[i].diff()) line.pop_back();
        line.push_back(vec[i].diff());
    }
    cout << line.size();

    return 0;
}

Compilation message (stderr)

Main.cpp: In constructor 'person::person(int)':
Main.cpp:16:5: warning: 'person::X' is initialized with itself [-Winit-self]
   16 |     person (int E) : E(E), X(X) {}
      |     ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...