結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 44 ms
4,380 KB
testcase_14 AC 50 ms
4,384 KB
testcase_15 AC 47 ms
4,592 KB
testcase_16 AC 50 ms
4,400 KB
testcase_17 AC 58 ms
4,432 KB
testcase_18 AC 63 ms
4,480 KB
testcase_19 AC 64 ms
4,556 KB
testcase_20 AC 67 ms
4,684 KB
testcase_21 AC 52 ms
4,680 KB
testcase_22 AC 54 ms
4,504 KB
testcase_23 AC 55 ms
4,532 KB
testcase_24 AC 54 ms
4,480 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(n,N) rep(m,M) pos[n][m] = -1;
  rep(i,N*M){
    int n = inf.readInt(1,N);
    inf.readSpace();
    int m = inf.readInt(1,M);
    inf.readEoln();
    n--; m--;
    if(pos[n][m] != -1){
      string errmsg = string("") + "Pair of same cards found : " + 
                          "card " + vtos(pos[n][m]+1) + " and card " + vtos(i+1);
      inf.quit(_wa, errmsg.c_str());
    }
    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