結果

問題 No.2573 moving up
ユーザー kwm_tkwm_t
提出日時 2023-12-30 15:31:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,387 bytes
コンパイル時間 4,641 ms
コンパイル使用メモリ 280,800 KB
実行使用メモリ 10,464 KB
最終ジャッジ日時 2023-12-30 15:31:21
合計ジャッジ時間 6,384 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 97 ms
10,464 KB
testcase_02 WA -
testcase_03 AC 42 ms
10,464 KB
testcase_04 WA -
testcase_05 AC 41 ms
10,464 KB
testcase_06 AC 38 ms
10,464 KB
testcase_07 AC 36 ms
10,176 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 WA -
testcase_10 AC 30 ms
9,096 KB
testcase_11 WA -
testcase_12 AC 17 ms
7,272 KB
testcase_13 WA -
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 WA -
testcase_17 AC 11 ms
6,676 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 4 ms
6,676 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 4 ms
6,676 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//using mint = modint998244353;
//const int mod = 998244353;
//using mint = modint1000000007;
//const int mod = 1000000007;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h, w; cin >> h >> w;
	int sz = (w + w + h - 1)*h / 2;
	vector<vector<int>>to(sz);
	int s = w * 2;
	int t = s + 1;
	mcf_graph<int, long long>g(t + 1);
	rep(i, w) {
		int x, y; cin >> x >> y;
		x--, y--;
		int l = y - x;
		int r = y;
		rep(j, w) {
			int c = 0;
			if (l <= j && j <= r) c = x;
			else c = x + abs(y - j);
			g.add_edge(i, w + j, 1, c);
		}
	}
	rep(i, w) {
		g.add_edge(s, i, 1, 0);
		g.add_edge(i + w, t, 1, 0);
	}
	auto result = g.flow(s, t, w);
	cout << result.second << endl;
	return 0;
}
0