結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 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(N>K)
		{
			if(K-1<=A)
			{
				cout<<(A-(K-1))/K<<endl;
			}
			else if(N-K+1<=W)
			{
				cout<<-1<<endl;
			}
			else
			{
				cout<<":("<<endl;
			}
		}
		else
		{
			if(W%N==0)
			{
				if(A>=N-1)
				{
					long S=0;
					long T=W/N;
					S-=T*(T+1)/2;
					S+=(A-(N-1))/N;
					cout<<S<<endl;
				}
				else if(W>0)
				{
					long S=0;
					long T=W/N;
					S-=T*(T+1)/2;
					S-=T+1;
					if(A<=T)S+=A;
					else S+=T;
					cout<<S<<endl;
				}
				else
				{
					cout<<":("<<endl;
				}
			}
			else
			{
				int n=W%N;
				long S=0;
				long T=W/N;
				S-=T*(T+1)/2;
				T++;
				S-=T;
				if(T*n<=A)
				{
					S+=T;
					A-=T*n;
					if(A>=N-1)S+=(A-(N-1))/N;
					else
					{
						S-=T;
						if(A<T)S+=A;
						else S+=T-1;
					}
				}
				else
				{
					N=n;
					if(A>=N-1)S+=(A-(N-1))/N;
					else
					{
						S-=T+1;
						if(A<=T)S+=A;
						else S+=T;
					}
				}
				cout<<S<<endl;
			}
		}
	}
}
0