結果
問題 | No.1060 素敵な宝箱 |
ユーザー |
![]() |
提出日時 | 2020-05-22 23:06:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 1,464 bytes |
コンパイル時間 | 2,539 ms |
コンパイル使用メモリ | 202,772 KB |
最終ジャッジ日時 | 2025-01-10 15:01:09 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> #define FASTIO using namespace std; using ll = long long; using Vi = vector<int>; using Vl = vector<ll>; using Pii = pair<int, int>; using Pll = pair<ll, ll>; constexpr int I_INF = numeric_limits<int>::max(); constexpr ll L_INF = numeric_limits<ll>::max(); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void solve() { ll N, M; cin >> N >> M; vector<Vl> A(N, Vl(M)); for (ll i = 0; i < N; i++) { for (ll j = 0; j < M; j++) { cin >> A[i][j]; } } Vl ds(M); for (ll j = 0; j < M; j++) { for (ll i = 0; i < N; i++) { ds[j] += A[i][j]; } } Vl es(N); for (ll i = 0; i < N; i++) { for (ll j = 0; j < M; j++) { es[i] += A[i][j] * ds[j]; } } sort(es.begin(), es.end(), greater<ll>()); ll ans = 0; for (ll i = 0; i < N; i++) { if (i & 1) { ans -= es[i]; } else { ans += es[i]; } } cout << ans << "\n"; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% int main() { #ifdef FASTIO cin.tie(0), cout.tie(0); ios::sync_with_stdio(false); #endif #ifdef FILEINPUT ifstream ifs("./in_out/input.txt"); cin.rdbuf(ifs.rdbuf()); #endif #ifdef FILEOUTPUT ofstream ofs("./in_out/output.txt"); cout.rdbuf(ofs.rdbuf()); #endif solve(); cout << flush; return 0; }