結果

問題 No.2119 一般化百五減算
ユーザー 👑 chro_96chro_96
提出日時 2022-11-04 21:53:11
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 837 bytes
コンパイル時間 1,311 ms
コンパイル使用メモリ 28,256 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-26 00:15:55
合計ジャッジ時間 1,561 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,500 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 19 ms
4,380 KB
testcase_21 AC 20 ms
4,380 KB
testcase_22 AC 27 ms
4,376 KB
testcase_23 AC 26 ms
4,380 KB
testcase_24 AC 27 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int m = 0;
  int b[100000] = {};
  int c[100000] = {};
  
  int res = 0;
  
  int prev[100001] = {};
  
  int ap[100001] = {};
  int cnt = 0;
  int is_ok = 1;
  
  int ans = 0;
  
  res = scanf("%d", &n);
  res = scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    res = scanf("%d", b+i);
    res = scanf("%d", c+i);
    if (c[i] < 0) {
      c[i] += (1+(-c[i])/b[i])*b[i];
    }
    if (prev[b[i]] > 0) {
      int idx = prev[b[i]]-1;
      if (c[i]%b[i] == c[idx]%b[idx]) {
        is_ok = 0;
      }
    } else {
      for (int j = c[i]%b[i]; j <= n; j += b[i]) {
        ap[j]++;
      }
      cnt++;
    }
    prev[b[i]] = i+1;
  }
  
  while (ans <= n) {
    if (ap[ans] >= cnt) {
      printf("%d\n", ans);
      return 0;
    }
    ans++;
  }
  
  printf("NaN\n");
  return 0;
}
0