제출 #367368

#제출 시각아이디문제언어결과실행 시간메모리
367368534351Arcade (NOI20_arcade)C++17
100 / 100
251 ms14060 KiB
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

const int MAXN = 1e6 + 13;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
pii arr[MAXN];
multiset<int> vals;
int ans;

int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N >> N;
    FOR(i, 0, N)
    {
        cin >> arr[i].fi;
    }
    FOR(i, 0, N)
    {
        cin >> arr[i].se;
    }
    FOR(i, 0, N)
    {
        arr[i] = {arr[i].fi + arr[i].se, arr[i].fi - arr[i].se};
        // cerr << arr[i].fi << ',' << arr[i].se << endl;
    }
    sort(arr, arr + N);
    FOR(i, 0, N)
    {
        int c = arr[i].se;
        if (vals.empty() || c < *vals.begin())
        {
            vals.insert(c);
            ans++;
        }
        else
        {
            auto it = prev(vals.UB(c));
            vals.erase(it);
            vals.insert(c);
        }
    }
    cout << ans << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...