結果
問題 |
No.2422 regisys?
|
ユーザー |
|
提出日時 | 2023-08-12 15:36:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,303 bytes |
コンパイル時間 | 4,102 ms |
コンパイル使用メモリ | 239,844 KB |
実行使用メモリ | 90,796 KB |
最終ジャッジ日時 | 2024-11-20 03:35:29 |
合計ジャッジ時間 | 33,459 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 TLE * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #include<atcoder/all> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m, v; cin >> n >> m; vector<pair<int,int>> a(n), b(n); for(int i = 0; i < n; i++){ cin >> v; a[i] = {v, i}; } for(int i = 0; i < n; i++){ cin >> v; b[i] = {v, i}; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); atcoder::mf_graph<int> g(3 * n + 2); int s = 3 * n, t = s + 1; for(int i = 0; i < n; i++){ g.add_edge(i, 2 * n + i, 1); g.add_edge(n + i, 2 * n + i, 1); g.add_edge(2 * n + i, t, 1); if(i + 1 < n){ g.add_edge(a[i + 1].second, a[i].second, n); g.add_edge(b[i + 1].second + n, b[i].second + n, n); } } for(int i = 0; i < m; i++){ int c; cin >> c >> v; if(c == 0){ int id = upper_bound(a.begin(), a.end(), make_pair(v, n + 1)) - a.begin(); if(id >= 1) g.add_edge(s, a[id - 1].second, 1); }else{ int id = upper_bound(b.begin(), b.end(), make_pair(v, n + 1)) - b.begin(); if(id >= 1) g.add_edge(s, b[id - 1].second + n, 1); } } cout << n - g.flow(s, t) << '\n'; }