結果

問題 No.1060 素敵な宝箱
ユーザー yurujirouyurujirou
提出日時 2021-09-24 17:30:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,232 bytes
コンパイル時間 3,172 ms
コンパイル使用メモリ 175,688 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 20:17:14
合計ジャッジ時間 5,606 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>
using namespace std;

#include <atcoder/all>
using namespace atcoder;

#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 LREP(i,n) for(LL i = 0; i < (LL)n; i++)

#define Vi vector<int>
#define Vl vector<long long>
#define LP pair<long long ,long long>
#define P pair<int, int>
#define T3 tuple<LL, LL, LL>
#define T4 tuple<LL, LL, LL, LL>
#define INF 1000000007
#define SIZE	310
#define MOD 1000000007
typedef long long LL;

LL N, M;
LL A[SIZE][SIZE];
LL C[SIZE];

int main() {
	cin >> N >> M;
	REP(i, N) REP(j, M) cin >> A[i][j];

	REP(j, M) {
		LL c = 0;
		REP(i, N) {
			c += A[i][j];
		}
		C[j] = c;
	}

	Vl X;
	REP(i, N) {
		LL cost = 0;
		REP(j, M) {
			cost += A[i][j] * C[j];
		}
		X.push_back(cost);
	}
	sort(X.begin(), X.end(), greater<LL>());
	LL ans = 0;
	REP(i, N) {
		if (i % 2 == 0) ans += X[i];
		else ans -= X[i];
	}
	cout << ans << endl;
}
0