結果
問題 | No.1060 素敵な宝箱 |
ユーザー |
![]() |
提出日時 | 2020-05-23 00:07:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 970 bytes |
コンパイル時間 | 1,609 ms |
コンパイル使用メモリ | 122,232 KB |
最終ジャッジ日時 | 2025-01-10 15:08:43 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <iostream> #include <algorithm> #include <numeric> #include <vector> #include <string> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <iomanip> #include <functional> #include <bitset> #include <limits> #include <cstdio> #include <cmath> #include <cassert> #ifdef DEBUG #include "library/Utility/debug.cpp" #else #define debug(...) #endif #define rep(i,n) for(int i=0;i<(n);++i) #define EL '\n' #define print(i) std::cout << (i) << '\n' #define all(v) (v).begin(), (v).end() using lnt = long long; constexpr lnt INF = 2e18; /*-*/ int main() { int n,m; std::cin >> n >> m; std::vector<std::vector<lnt> > a(n,std::vector<lnt>(m)); rep(i,n) rep(j,m) std::cin >> a[i][j]; std::vector<lnt> c(m,0); rep(i,n) rep(j,m) c[j]+=a[i][j]; std::vector<lnt> b(n,0); rep(i,n) { rep(j,m) b[i]+=c[j]*a[i][j]; } std::sort(b.rbegin(),b.rend()); lnt x=0,y=0; rep(i,n) { if(i&1) y+=b[i]; else x+=b[i]; } print(x-y); }