結果
問題 | No.1060 素敵な宝箱 |
ユーザー | merom686 |
提出日時 | 2020-05-22 23:04:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 955 bytes |
コンパイル時間 | 1,365 ms |
コンパイル使用メモリ | 98,992 KB |
最終ジャッジ日時 | 2025-01-10 15:00:32 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)); vector<int> s(m, 0), t(n, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; s[j] += a[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { t[i] += a[i][j] * s[j]; } } sort(t.rbegin(), t.rend()); ll r = 0; for (int i = 0; i < n; i += 2) { r += t[i] - t[i + 1]; } cout << r << endl; // 単に多いのから取っていく // 宝石が1種類なら? 単に多いのから // 宝石jを1個取られる毎に2*s[j]の損 1個がs[j]の価値 return 0; }