結果
| 問題 |
No.1060 素敵な宝箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-22 23:05:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 1,137 bytes |
| コンパイル時間 | 2,539 ms |
| コンパイル使用メモリ | 204,920 KB |
| 最終ジャッジ日時 | 2025-01-10 15:00:44 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h> // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif // clang-format on
/**
* author: knshnb
* created: Fri May 22 22:59:44 JST 2020
**/
template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}
signed main() {
Int n, m;
std::cin >> n >> m;
auto a = make_vec<Int>(n, m, 0);
std::vector<Int> sum(m);
REP(i, n) REP(j, m) std::cin >> a[i][j], sum[j] += a[i][j];
std::vector<Int> score(n);
REP(i, n) REP(j, m) score[i] += a[i][j] * sum[j];
std::sort(score.rbegin(), score.rend());
Int ans = 0;
REP(i, n) { ans += i % 2 ? -score[i] : score[i]; }
std::cout << ans << std::endl;
}