結果

問題 No.1440 The Quiz Competition
ユーザー SSRS
提出日時 2021-03-26 22:46:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 167,000 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-29 00:42:58
合計ジャッジ時間 2,310 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    int N, A, W, K;
    cin >> N >> A >> W >> K;
    if (K != N || W == 0){
      if (A < K - 1){
        if (W >= N - K + 1){
          cout << -1 << endl;
        } else {
          cout << ":(" << endl;
        }
      } else if (A % K == K - 1){
        cout << A / K << endl;
      } else {
        cout << A / K - 1 << endl;
      }
    } else {
      long long sum = A - (long long) W * (W + 1) / 2;
      int r = (sum % N + N) % N;
      long long q = (sum - r) / N;
      if (r == N - 1){
        cout << q << endl;
      } else {
        cout << q - 1 << endl;
      }
    }
  }
}
0