結果
問題 |
No.1060 素敵な宝箱
|
ユーザー |
|
提出日時 | 2024-09-11 16:18:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 619 bytes |
コンパイル時間 | 2,144 ms |
コンパイル使用メモリ | 201,836 KB |
最終ジャッジ日時 | 2025-02-24 06:39:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll N,M; cin>>N>>M; vector<ll> S(M,0); vector<vector<ll>> A(N,vector<ll>(M)); for(int i=0;i<N;i++){ for(int j=0;j<M;j++){ cin>>A[i][j]; S[j]+=A[i][j]; } } vector<ll> D(N,0); for(int i=0;i<N;i++){ for(int j=0;j<M;j++)D[i]+=S[j]*A[i][j]; } sort(D.begin(),D.end()); reverse(D.begin(),D.end()); ll an=0; for(int i=0;i<N;i++){ an+=D[i]*(1-(i%2)*2); } cout<<an<<endl; }