結果
問題 |
No.1467 Selling Cars
|
ユーザー |
|
提出日時 | 2021-04-02 22:52:13 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 880 bytes |
コンパイル時間 | 3,283 ms |
コンパイル使用メモリ | 134,544 KB |
実行使用メモリ | 409,036 KB |
最終ジャッジ日時 | 2024-12-23 20:59:04 |
合計ジャッジ時間 | 150,697 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 1 WA * 2 TLE * 28 |
ソースコード
#define rep(i, l, r) for (auto i = (l); i < (r); i++) #define chmin(dest, src) if ((dest) > (src)) dest = (src) #define chmax(dest, src) if ((dest) < (src)) dest = (src) #include <iostream> #include <vector> #include <algorithm> using namespace std; #include <atcoder/mincostflow> using namespace atcoder; using ll = int; int main() { int M, N; cin >> M >> N; vector<ll> A(N); rep(i, 0, N) cin >> A[i]; vector<ll> B(M); rep(i, 0, M) cin >> B[i]; rep(k, 1, M + 1) { mcf_graph<int, ll> graph(N + M + 2); int s = N + M; int t = N + M + 1; rep(i, 0, N) { graph.add_edge(s, i, 1, 0); } rep(i, 0, N) rep(j, 0, M) { graph.add_edge(i, N + j, 1, abs(A[i] - B[j])); } rep(i, 0, M) { graph.add_edge(N + i, t, k, 0); } auto result = graph.flow(s, t); auto cost = result.second; cout << cost << endl; } return 0; }