結果

問題 No.2463 ストレートフラッシュ
ユーザー 👑 NachiaNachia
提出日時 2021-05-08 15:46:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 871 bytes
コンパイル時間 5,668 ms
コンパイル使用メモリ 213,000 KB
実行使用メモリ 4,752 KB
最終ジャッジ日時 2023-09-08 21:15:14
合計ジャッジ時間 8,189 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 43 ms
4,388 KB
testcase_14 AC 49 ms
4,380 KB
testcase_15 AC 46 ms
4,384 KB
testcase_16 AC 49 ms
4,380 KB
testcase_17 AC 57 ms
4,452 KB
testcase_18 AC 62 ms
4,528 KB
testcase_19 AC 62 ms
4,452 KB
testcase_20 AC 62 ms
4,752 KB
testcase_21 AC 50 ms
4,544 KB
testcase_22 AC 52 ms
4,452 KB
testcase_23 AC 54 ms
4,476 KB
testcase_24 AC 53 ms
4,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"

#include <algorithm>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int N,M;
int pos[501][500]={};
int sfPos[5]={};

int solve_per_sfPos(){
  int ans=0;
  int remain=0, p=0;
  rep(i,5){
    remain+=sfPos[i]-p; p=sfPos[i]+1;
    ans+=remain/(5-i);
    remain%=(5-i);
  }
  return ans;
}

int main(){
  registerValidation();
  N = inf.readInt(5,500);
  inf.readSpace();
  M = inf.readInt(1,500);
  inf.readEoln();
  rep(i,N*M){
    int n = inf.readInt(1,N);
    inf.readSpace();
    int m = inf.readInt(1,M);
    inf.readEoln();
    n--; m--;
    pos[n][m]=i;
  }
  rep(i,M) pos[N][i]=pos[0][i];
  inf.readEof();

  int ans=1000000000;
  for(int ns=0; ns<=N-4; ns++) rep(m,M) {
    rep(i,5) sfPos[i]=pos[ns+i][m];
    sort(sfPos,sfPos+5);
    ans=min(ans,solve_per_sfPos());
  }
  cout<<ans<<"\n";

  return 0;
}
0