結果
| 問題 | No.2921 Seated in Classroom | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2024-10-13 16:19:33 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 88 ms / 2,000 ms | 
| コード長 | 570 bytes | 
| コンパイル時間 | 339 ms | 
| コンパイル使用メモリ | 40,064 KB | 
| 最終ジャッジ日時 | 2025-02-24 19:16:35 | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |   scanf("%d", &tn);
      |   ~~~~~^~~~~~~~~~~
main.cpp:29:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
            
            ソースコード
/* -*- coding: utf-8 -*-
 *
 * 2921.cc:  No.2921 Seated in Classroom - yukicoder
 */
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
/* typedef */
using ll = long long;
/* global variables */
/* subroutines */
/* main */
int main() {
  int tn;
  scanf("%d", &tn);
  while (tn--) {
    int n, m;
    scanf("%d%d", &n, &m);
    int x0 = 0, x1 = n + m;
    while (x0 + 1 < x1) {
      int x = ((ll)x0 + x1) / 2;
      if ((ll)x * 4 >= n && (ll)x * 8 >= n + m) x1 = x;
      else x0 = x;
    }
    printf("%d\n", x1);
  }
  return 0;
}
            
            
            
        