結果

問題 No.1028 闇討ち
ユーザー konchanksukonchanksu
提出日時 2020-04-17 23:14:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 646 bytes
コンパイル時間 809 ms
コンパイル使用メモリ 72,328 KB
実行使用メモリ 13,844 KB
最終ジャッジ日時 2024-04-14 15:31:17
合計ジャッジ時間 5,384 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,660 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 25 ms
6,940 KB
testcase_10 AC 40 ms
6,940 KB
testcase_11 AC 299 ms
6,940 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int n, i, j, k;

int main(){
    cin >> n;
    int a[n][n];
    for(i = 0; i < n; i++){for(j = 0; j < n; j++){cin >> a[i][j];}}
    
    int ans[n], tmp[n];
    for(i = 0; i < n; i++){ans[i] = 1000000000;}
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){tmp[j] = 0;}
        for(j = 0; j < n; j++){
            for(k = 0; k < n; k++){
                tmp[a[k][j] - 1] += max(j, abs(i - k));
            }
        }
        
        for(j = 0; j < n; j++){ans[j] = min(tmp[j], ans[j]);}
    }    
    k = 0;
    for(i = 0; i < n; i++) {k += ans[i];}
    cout << k << endl;
    return 0;
}
0