結果

問題 No.1440 The Quiz Competition
ユーザー kotatsugamekotatsugame
提出日時 2021-03-27 01:41:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 844 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 65,672 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-19 12:22:11
合計ジャッジ時間 1,677 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    4 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int T;
main()
{
	cin>>T;
	for(;T--;)
	{
		int N,A,W,K;
		cin>>N>>A>>W>>K;
		if(A<K-1&&N-K+1>W)
		{
			cout<<":("<<endl;
		}
		else if(N>K)
		{
			if(K-1<=A)
			{
				cout<<(A-(K-1))/K<<endl;
			}
			else//if(N-K+1<=W)
			{
				cout<<-1<<endl;
			}
		}
		else
		{
			if(W%N==0)
			{
				if(A>=N-1)
				{
					long S=0;
					long T=W/N;
					S-=T*(T+1)/2;
					if(A>=N-1)S+=(A-(N-1))/N;
					cout<<S<<endl;
				}
				else//if(W>0)
				{
					long S=0;
					long T=W/N-1;
					S-=T*(T+1)/2;
					S-=T+1;
					cout<<S<<endl;
				}
			}
			else
			{
				int n=W%N;
				long S=0;
				long T=W/N;
				S-=T*(T+1)/2;
				T++;
				S-=T;
				if(n-1<=A)
				{
					A-=n-1;
					int a=A/n;
					if(a<T)S+=a;
					else
					{
						S+=T-1;
						A-=(T-1)*n;
						S+=A/N;
					}
				}
				cout<<S<<endl;
			}
		}
	}
}
0