結果
| 問題 |
No.2463 ストレートフラッシュ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-11 15:32:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 2,000 ms |
| コード長 | 685 bytes |
| コンパイル時間 | 2,257 ms |
| コンパイル使用メモリ | 202,196 KB |
| 最終ジャッジ日時 | 2025-02-16 21:38:20 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
vector C2idx(N,vector(M,0));
for(int i=0;i<N*M;i++){
int a,b;
cin>>a>>b;
--a,--b;
C2idx[a][b]=i;
}
int ans=N*M;
for(int i=0;i<N-3;i++){
for(int j=0;j<M;j++){
vector<int>idcs;
for(int k=i;k<i+5;k++){
idcs.push_back(C2idx[k%N][j]);
}
sort(idcs.begin(),idcs.end());
int now=0,t=4;
for(int k=0;k<5;k++){
if(t>=idcs[k])continue;
int s=(idcs[k]-t+4-k)/(5-k);
now+=s,t+=s*(5-k);
}
ans=min(ans,now);
}
}
cout<<ans<<'\n';
}