結果
| 問題 | No.9 モンスターのレベル上げ |
| コンテスト | |
| ユーザー |
FF256grhy
|
| 提出日時 | 2015-05-12 08:45:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,262 bytes |
| コンパイル時間 | 136 ms |
| コンパイル使用メモリ | 23,680 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 23:57:44 |
| 合計ジャッジ時間 | 3,974 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:11:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | for(i = 0; i < n; i++) { scanf("%d", &a[i]); }
| ~~~~~^~~~~~~~~~~~~
main.cpp:12:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | for(i = 0; i < n; i++) { scanf("%d", &b[i]); b[i] /= 2; }
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h>
void make_table();
void add(int, int);
int n, a[1500], b[1500], table[15001], buttle[1501], next[1501];
int main(void) {
scanf("%d", &n);
int i, j;
for(i = 0; i < n; i++) { scanf("%d", &a[i]); }
for(i = 0; i < n; i++) { scanf("%d", &b[i]); b[i] /= 2; }
int min = 1501;
for(i = 0; i < n; i++) { // i: 開始位置
int max = 0;
make_table();
int min_p = 0;
for(j = 0; j < n; j++) {
int k = (i + j) % n;
int l = min_p;
while(table[l] == 0) { l++; }
min_p = l;
int p = table[l];
table[l] = next[p];
buttle[p]++;
max = max < buttle[p] ? buttle[p] : max;
add(l + b[k], p);
}
min = max < min ? max : min;
}
printf("%d\n", min);
return 0;
}
void make_table() {
int i;
for(i = 0; i < 15001; i++) { table[i] = 0; }
for(i = 0; i < 1501; i++) { buttle[i] = 0; next[i] = 0; }
for(i = 0; i < n; i++) {
next[i + 1] = table[ a[i] ]; // 先頭につないでいく
table[ a[i] ] = i + 1;
}
buttle[0] = 1501; // 番兵
return;
}
void add(int l, int p) {
if(buttle[p] <= buttle[ table[l] ]) {
next[p] = next[ table[l] ];
table[l] = p;
} else {
int q = table[l];
while( buttle[ next[q] ] < buttle[p] ) { q = next[q]; }
next[p] = next[q];
next[q] = p;
}
return;
}
FF256grhy