結果
問題 |
No.1060 素敵な宝箱
|
ユーザー |
![]() |
提出日時 | 2020-05-22 22:37:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,018 bytes |
コンパイル時間 | 2,183 ms |
コンパイル使用メモリ | 210,992 KB |
最終ジャッジ日時 | 2025-01-10 14:55:50 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 WA * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long int; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++) #define REP(i, n) FOR(i,0,n) template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; } #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; int main() { int N, M; cin >> N >> M; vector<pair<int, vector<int>>> A; REP(i, N) { vector<int> v(M); cin >> v; A.emplace_back(-accumulate(v.begin(), v.end(), 0), v); } sort(A.begin(), A.end()); vector<vector<lint>> d(2, vector<lint>(M)); bool b = false; for (auto x : A) { REP(i, M) d[b][i] += x.second[i]; b = !b; } lint ret = 0; REP(i, M) ret += d[0][i] * d[0][i] - d[1][i] * d[1][i]; cout << ret << '\n'; }