結果

問題 No.1060 素敵な宝箱
ユーザー chocopuuchocopuu
提出日時 2020-05-22 22:14:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,468 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 201,376 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 17:08:29
合計ジャッジ時間 3,397 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)

void solve(){
	int N,M;
	cin >> N >> M;
	vector<vector<int>>c(N,vector<int>(M));
	REP(i,N){
		REP(j,M){
			cin >> c[i][j];
		}
	}
	vector<int>a(M),b(M);
	vector<int>used(N);
	REP(i,N){
		int ma = -INF,idx = -1;
		REP(j,N){
			if(used[j])continue;
			auto next = a;
			if(i % 2)next = b;
			REP(k,M){
				next[k] += c[j][k];
			}
			int sum = 0;
			REP(k,M){
				sum += next[k] * next[k];
			}
			if(CHMAX(ma,sum)){
				idx = j;
			}
		}
		if(i % 2){
			REP(j,M)b[j] += c[idx][j];
		}else{
			REP(j,M)a[j] += c[idx][j];
		}
		used[idx] = 1;
	}
	int ans = 0;
	REP(i,M)ans += a[i] * a[i] - b[i] * b[i];
	out(ans);
}

signed main(){
	IOS();
	int Q = 1;
	//cin >> Q;
	while(Q--)solve();
}
0