結果

問題 No.2463 ストレートフラッシュ
ユーザー PAKACHUPAKACHU
提出日時 2023-09-08 23:08:17
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 1,276 bytes
コンパイル時間 4,945 ms
コンパイル使用メモリ 134,012 KB
実行使用メモリ 4,444 KB
最終ジャッジ日時 2023-09-08 23:08:26
合計ジャッジ時間 8,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 3 ms
4,384 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 105 ms
4,384 KB
testcase_14 AC 121 ms
4,384 KB
testcase_15 AC 116 ms
4,384 KB
testcase_16 AC 123 ms
4,384 KB
testcase_17 AC 143 ms
4,384 KB
testcase_18 AC 157 ms
4,444 KB
testcase_19 AC 155 ms
4,392 KB
testcase_20 AC 155 ms
4,436 KB
testcase_21 AC 145 ms
4,388 KB
testcase_22 AC 147 ms
4,380 KB
testcase_23 AC 148 ms
4,440 KB
testcase_24 AC 148 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const long long mod = 998244353;
const ll inf = 1LL << 60;
const int INF = 5e8;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n, vector<int>(m));

    for (int i = 0; i < n * m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (i < 5)
            continue;
        v[a][b] = i - 4;
    }

    int ans = INF;
    for (int j = 0; j < m; j++) {
        for (int i = 0; i < n - 3; i++) {
            int ret = 0;
            vector<int> vec;
            for (int k = 0; k < 5; k++)
                vec.push_back(v[(i + k) % n][j]);
            sort(vec.begin(), vec.end());
            int cnt = 5;
            int pos = 0;
            while (cnt) {
                if (vec[5 - cnt] <= pos) {
                    cnt--;
                    continue;
                }
                int step = (vec[5 - cnt] - pos - 1) / cnt + 1;
                ret += step;
                pos += cnt * step;
                cnt--;
            }
            ans = min(ans, ret);
        }
    }
    cout << ans << endl;
}
0