結果
問題 |
No.1703 Much Matching
|
ユーザー |
![]() |
提出日時 | 2021-10-08 22:17:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,955 bytes |
コンパイル時間 | 709 ms |
コンパイル使用メモリ | 45,816 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-23 04:46:57 |
合計ジャッジ時間 | 4,203 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 RE * 16 |
ソースコード
#pragma GCC optimize ("O3") #pragma GCC target ("avx") //#include<bits/stdc++.h> #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define Would #define you #define please const int cm = 1 << 17; char cn[cm], * ci = cn + cm, ct; inline char getcha() { if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; } return *ci++; } inline int getint() { int A = 0; if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0'; else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0'; return A; } void pakuri_sort(int N, ll A[]) { const int b = 9; ll tmp[100001]; rep(k, 4) { int kazu[1 << b] = {}, kazu2[1 << b] = {}; rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++; rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i]; for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i]; k++; rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++; rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i]; for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i]; } } int main() { //cin.tie(0); //ios::sync_with_stdio(false); getint();getint(); int N = getint(); ll HW[100000]; rep(i, N) { HW[i] = ((ll)getint() << 18) + 100000 - getint(); } pakuri_sort(N, HW); int dp[100000]; int k = 0; int saidai = 0; const int m = (1 << 18) - 1; rep(i, N) { int h = 100000 - (HW[i] & m); if (saidai < h) { dp[k++] = h; saidai = h; } else { auto itr = lower_bound(dp, dp + k, h); if (itr == dp + k - 1) saidai = h; *itr = h; } } printf("%d", k); Would you please return 0; }