結果

問題 No.1060 素敵な宝箱
ユーザー minatominato
提出日時 2020-05-22 22:20:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,951 bytes
コンパイル時間 3,759 ms
コンパイル使用メモリ 236,756 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 17:16:21
合計ジャッジ時間 4,814 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,944 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 #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<ll>> A(N, vector<ll>(M));
    rep(i,N) rep(j,M) cin >> A[i][j];
    vector<ll> P(M),Q(M);
    vector<bool> check(N);
    rep(turn,N) {
        ll result = -1;
        ll num = -1; 
        rep(i,N) {
            if (!check[i]) {
                if (turn&1) {
                    ll val = 0;
                    rep(j,M) {
                        val += (Q[j]+A[i][j])*(Q[j]+A[i][j]);
                    }
                    if (chmax(result,val)) num = i;
                } else {
                    ll val = 0;
                    rep(j,M) {
                        val += (P[j]+A[i][j])*(P[j]+A[i][j]);
                    }
                    if (chmax(result,val)) num = i;
                }
            }
        }
        rep(i,M) {
            if (turn&1) {
                Q[i] += A[num][i];
            } else {
                P[i] += A[num][i];
            }
        }
        check[num] = 1;
    }

    ll ans = 0;
    rep(i,M) {
        ans += P[i]*P[i] - Q[i]*Q[i];
    }

    cout << ans << ln;
}
0