結果

問題 No.1060 素敵な宝箱
ユーザー soto800soto800
提出日時 2020-05-22 23:00:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,885 bytes
コンパイル時間 1,534 ms
コンパイル使用メモリ 163,600 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 18:20:09
合計ジャッジ時間 2,530 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

lli a[400][400];

lli sumC[400];
lli sumA[2][400];

lli cnt[400];

bool useFlag[400];

int main(){

    lli n,m;
    cin>>n>>m;

    REP(i,0,n){
        REP(j,0,m){
            cin>>a[i][j];
            sumC[j] += a[i][j];
        }
    }

    REP(i,0,n)cnt[i]=-1;

    REP(i,0,n){
        lli index = -1;
        lli minSum = -INF;

        REP(j,0,n){
            if(useFlag[j])continue;
            lli sum = 0;
            REP(k,0,m){
                sum += sumC[k]*sumC[k] + (sumC[k]-a[j][k])*(sumC[k]-a[j][k]);
            }
            if(sum > minSum){
                minSum = sum;
                index = j;
            }
        }
        REP(k,0,m){
            sumA[i%2][k] += a[index][k];
            sumC[k] -= a[index][k];
        }
        useFlag[index]=true;
    }

    lli ans[2]={0,0};

    REP(i,0,2){
        REP(j,0,m){
            ans[i] += sumA[i][j]*sumA[i][j];
        } 
    }

    cout<<abs(ans[0]-ans[1])<<endl;






    return 0;
}
0