結果
| 問題 |
No.2463 ストレートフラッシュ
|
| コンテスト | |
| ユーザー |
planes
|
| 提出日時 | 2023-09-08 21:55:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 2,000 ms |
| コード長 | 973 bytes |
| コンパイル時間 | 1,665 ms |
| コンパイル使用メモリ | 175,572 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-26 14:53:13 |
| 合計ジャッジ時間 | 3,741 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
ll INF=2e18;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll N,M;cin>>N>>M;
vector<vector<ll>> od(M,vector<ll> (N+1));
for(ll i=1;i<=N*M;i++) {
ll n,m;cin>>n>>m;
m--;
od[m][n]=i;
}
ll ans=INF;
for(ll i=0;i<M;i++) {
for(ll j=1;j<=N-3;j++) {
vector<ll> note(0);
for(ll h=0;h<5;h++) {
if(j+h<=N) note.push_back(od[i][j+h]);
else note.push_back(od[i][1]);
}
sort(all(note));
ll count=0;
ll ind=0;
ll last=0;
while(ind<5) {
count+=(note[ind]-last-1)/(5-ind);
last+=(note[ind]-last-1)/(5-ind)*(5-ind);
last+=(5-ind);
count++;
while(ind<5&&last>=note[ind]) {
ind++;
}
}
count--;
ans=min(ans,count);
}
}
cout<<ans<<endl;
}
planes