結果
| 問題 |
No.1060 素敵な宝箱
|
| コンテスト | |
| ユーザー |
pockyny
|
| 提出日時 | 2020-05-22 22:03:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 975 bytes |
| コンパイル時間 | 919 ms |
| コンパイル使用メモリ | 77,816 KB |
| 最終ジャッジ日時 | 2025-01-10 14:44:20 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
priority_queue<pair<ll,ll>> que;
long long a[310][310],s[310] = {},fir[310] = {},sec[310] = {};
int main(){
int i,j,n,m;
cin >> n >> m;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
cin >> a[i][j];
s[j] += a[i][j];
}
}
for(i=0;i<n;i++){
ll sc = 0;
for(j=0;j<m;j++){
sc += s[j]*a[i][j];
}
que.push({sc,i});
}
int f = 1;
while(que.size()){
pair<ll,ll> p = que.top();
que.pop();
i = p.second;
if(f==1){
for(j=0;j<m;j++){
fir[j] += a[i][j];
}
}else{
for(j=0;j<m;j++){
sec[j] += a[i][j];
}
}
f *= -1;
}
ll x = 0,y = 0;
for(j=0;j<m;j++){
x += fir[j]*fir[j];
y += sec[j]*sec[j];
}
cout << x - y << endl;
}
pockyny