結果

問題 No.519 アイドルユニット
ユーザー oshiborioshibori
提出日時 2017-05-28 21:57:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,310 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 170,416 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-21 14:10:55
合計ジャッジ時間 4,632 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,636 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 TLE -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<vector<int>>v(N, vector<int>(N));
	rep(i, 0, N)rep(j, 0, N)cin >> v[i][j];
	vector<pair<int, int>>m(N, pair<int, int>(-1, -1)), w(m);// 相手、スコア
	queue<int>q;
	rep(i, 0, N)q.push(i);
	while (!q.empty()) {
		int x = q.front(); q.pop();
		int index = distance(v[x].begin(), max_element(all(v[x])));
		if (w[index].second < v[x][index]) {
			w[index].second = v[x][index];
			if (w[index].first != -1)q.push(w[index].first);
			w[index].first = x;
		}
		else {
			v[x][index] = -1;
			q.push(x);
		}
	}
	int ans(0);
	rep(i, 0, N)ans += w[i].second;
	cout << ans / 2 << endl;
	return 0;
}
0