結果
| 問題 | No.3297 Bake Cookies | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2025-10-06 17:34:39 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 40 ms / 2,000 ms | 
| コード長 | 868 bytes | 
| コンパイル時間 | 364 ms | 
| コンパイル使用メモリ | 42,416 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-06 17:34:42 | 
| 合計ジャッジ時間 | 2,559 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |   scanf("%d%d%d", &n, &m, &t);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:40:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |   for (int i = 0; i < m; i++) scanf("%d", as + i), as[i]--;
      |                               ~~~~~^~~~~~~~~~~~~~
            
            ソースコード
/* -*- coding: utf-8 -*-
 *
 * 3297.cc:  No.3297 Bake Cookies - yukicoder
 */
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
const int MAX_M = 200000;
/* typedef */
using ll = long long;
/* global variables */
int as[MAX_M], cs[MAX_N];
/* subroutines */
bool check(int n, int t, int x) {
  ll rsum = 0;
  for (int i = 0; i < n; i++) {
    if (x >= cs[i]) rsum += (x - cs[i]) / t;
    else rsum -= (cs[i] - x);
  }
  return (rsum >= 0);
}
/* main */
int main() {
  int n, m, t;
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 0; i < m; i++) scanf("%d", as + i), as[i]--;
  for (int i = 0; i < m; i++) cs[as[i]]++;
  int x0 = -1, x1 = *max_element(cs, cs + n);
  while (x0 + 1 < x1) {
    int x = (x0 + x1) / 2;
    if (check(n, t, x)) x1 = x;
    else x0 = x;
  }
  printf("%d\n", x1);
  
  return 0;
}
            
            
            
        