結果
問題 | No.2463 ストレートフラッシュ |
ユーザー |
![]() |
提出日時 | 2023-09-08 21:34:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 187 ms / 2,000 ms |
コード長 | 952 bytes |
コンパイル時間 | 4,267 ms |
コンパイル使用メモリ | 255,060 KB |
最終ジャッジ日時 | 2025-02-16 19:39:11 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#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; }