結果
| 問題 |
No.1703 Much Matching
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-08 23:42:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 825 bytes |
| コンパイル時間 | 1,864 ms |
| コンパイル使用メモリ | 177,460 KB |
| 実行使用メモリ | 43,364 KB |
| 最終ジャッジ日時 | 2024-07-23 08:06:00 |
| 合計ジャッジ時間 | 9,777 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef pair<ll,ll> pl;
int main()
{
ll n,m,q;
cin >> n >> m >> q;
vector<ll> a(q),b(q),c(q,INF);
rep(i,q) cin >> a[i] >> b[i];
ll ma=0;
rep(i,q) {
ll pos=lower_bound(all(c),a[i])-c.begin();
c[pos]=a[i];
ma=max(ma,pos+1);
}
vector<pl> p;
rep(i,ma) rep(j,q) if(c[i]==a[j]) p.push_back({a[j],-b[j]});
sort(all(p));
ll ans=0;
c.assign(q,INF);
rep(i,(int)p.size()) {
ll pos=lower_bound(all(c),-p[i].second)-c.begin();
c[pos]=-p[i].second;
ans=max(ans,pos+1);
}
cout << ans << endl;
return 0;
}