結果

問題 No.1060 素敵な宝箱
ユーザー heno239heno239
提出日時 2020-05-23 02:01:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,249 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 121,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 23:00:29
合計ジャッジ時間 2,267 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<cassert>
#include<random>
#include<unordered_map>
#include<numeric>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define stop char nyaa;cin>>nyaa;


using P = pair<int, int>;
using ll = long long;
using LP = pair<ll, ll>;

const ll inf = 1000000007;
const ll INF = inf * inf;




void solve() {
	int n, m; cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));

	vector<int> s(m);
	rep(i, n)rep(j, m) {
		cin >> a[i][j];
		s[j] += a[i][j];
	}
	vector<ll> cost(n);
	rep(i, n) {
		rep(j, m) {
			cost[i] += 2 * s[j] * a[i][j];
		}
	}

	vector<LP> v;
	rep(i, n) {
		v.push_back({ cost[i],i });
	}
	sort(all(v), greater<LP>());
	ll ans = 0;
	for (int i = 0; i < v.size(); i += 2) {
		ans += v[i].first;
	}
	rep(j, m)ans -= (ll)s[j] * s[j];
	cout << ans << "\n";
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int t; cin >> t;rep(i, t)solve();
	solve();
	stop
	return 0;
}
0