結果

問題 No.2463 ストレートフラッシュ
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-16 11:40:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,361 bytes
コンパイル時間 2,725 ms
コンパイル使用メモリ 201,828 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-16 11:41:07
合計ジャッジ時間 6,910 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int N, M;
    cin >> N >> M;
    vector<int> n(N * M), m(N * M);
    for (int i = 0; i < N * M; i++) {
        cin >> n[i] >> m[i];
    }
    int ans = 1e9;
    for (int j = 1; j <= M; j++) {
        for (int st = 1; st <= N - 3; st++) {
            set<int> need_n;
            if (st < N - 3) {
                for (int k = st; k < st + 5; k++) {
                    need_n.insert(k);
                }
            } else {
                for (int k = N - 3; k <= N; k++) {
                    need_n.insert(k);
                }
                need_n.insert(1);
            }
            int cur = 0;
            for (int i = 0; i < 5; i++) {
                if (m[i] == j && need_n.count(n[i]) > 0) {
                    cur++;
                }
            }
            int op = 0;
            int i = 5;
            while (cur < 5) {
                int op_cnt = 5 - cur;
                op++;
                for (int k = 0; k < op_cnt; k++) {
                    if (m[i] == j && need_n.count(n[i]) > 0) {
                        cur++;
                    }
                    i++;
                }
            }
            ans = min(ans, op);
        }
    }
    cout << ans << endl;
}
0