結果
| 問題 |
No.2463 ストレートフラッシュ
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-09-08 22:08:47 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 2,000 ms |
| コード長 | 1,399 bytes |
| コンパイル時間 | 353 ms |
| コンパイル使用メモリ | 30,720 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 15:10:32 |
| 合計ジャッジ時間 | 2,280 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <stdio.h>
int main () {
int n = 0;
int m = 0;
int ni = 0;
int mi = 0;
int res = 0;
int ans = 0;
int pos[500][500] = {};
int tmp[5] = {};
res = scanf("%d", &n);
res = scanf("%d", &m);
for (int i = 0; i < n*m; i++) {
res = scanf("%d", &ni);
res = scanf("%d", &mi);
pos[mi-1][ni-1] = i;
}
ans = n*m;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n-3; j++) {
int tmpcnt = 0;
int tmppos = 4;
for (int k = 0; k < 5; k++) {
tmp[k] = pos[i][(j+k)%n];
}
for (int k = 4; k > 0; k--) {
for (int l = 0; l < k; l++) {
if (tmp[l] > tmp[l+1]) {
int s = tmp[l];
tmp[l] = tmp[l+1];
tmp[l+1] = s;
}
}
}
tmpcnt = tmp[0]/5;
tmppos = (1+tmp[0]/5)*5-1;
if (tmppos < tmp[1]) {
tmpcnt += 1+(tmp[1]-tmppos-1)/4;
tmppos += (1+(tmp[1]-tmppos-1)/4)*4;
}
if (tmppos < tmp[2]) {
tmpcnt += 1+(tmp[2]-tmppos-1)/3;
tmppos += (1+(tmp[2]-tmppos-1)/3)*3;
}
if (tmppos < tmp[3]) {
tmpcnt += 1+(tmp[3]-tmppos-1)/2;
tmppos += (1+(tmp[3]-tmppos-1)/2)*2;
}
if (tmppos < tmp[4]) {
tmpcnt += tmp[4]-tmppos;
tmppos = tmp[4];
}
if (tmpcnt < ans) {
ans = tmpcnt;
}
}
}
printf("%d\n", ans);
return 0;
}
chro_96