結果

問題 No.2463 ストレートフラッシュ
ユーザー 沙耶花沙耶花
提出日時 2023-09-08 21:34:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 952 bytes
コンパイル時間 4,162 ms
コンパイル使用メモリ 261,864 KB
実行使用メモリ 4,532 KB
最終ジャッジ日時 2023-09-08 21:34:14
合計ジャッジ時間 7,309 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 105 ms
4,376 KB
testcase_14 AC 123 ms
4,376 KB
testcase_15 AC 118 ms
4,376 KB
testcase_16 AC 124 ms
4,384 KB
testcase_17 AC 149 ms
4,376 KB
testcase_18 AC 158 ms
4,436 KB
testcase_19 AC 157 ms
4,376 KB
testcase_20 AC 157 ms
4,416 KB
testcase_21 AC 148 ms
4,532 KB
testcase_22 AC 153 ms
4,380 KB
testcase_23 AC 154 ms
4,432 KB
testcase_24 AC 151 ms
4,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001



int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector pos(N,vector<int> (M));
	rep(i,N*M){
		int x,y;
		cin>>x>>y;
		x--,y--;
		pos[x][y] = i;
	}
	int ans= Inf32;
	rep(ii,M){
		rep(j,N-3){
			vector<int> ps;
			rep(k,5){
				int t = (j+k)%N;
				ps.push_back(pos[t][ii]);
			}
			sort(ps.begin(),ps.end());
			int correct = 0;
			rep(i,ps.size()){
				if(ps[i]<5)correct ++;
			}
			int nxt = 5;
			int num = 0;
			while(correct!=5){
				int dist = ps[correct]+1 - nxt;
				int Cnt = (dist+(5-correct)-1) / (5-correct);
				num += Cnt;
				nxt += (5-correct) * Cnt;
				correct = 0;
				rep(i,ps.size()){
					if(ps[i]<nxt)correct++;
				}
			}
			ans = min(ans,num);
		}
	}
	cout<<ans<<endl;
	
	return 0;
}
0