結果
| 問題 |
No.1440 The Quiz Competition
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2021-03-26 23:25:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,314 bytes |
| コンパイル時間 | 1,842 ms |
| コンパイル使用メモリ | 192,656 KB |
| 最終ジャッジ日時 | 2025-01-19 23:35:42 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const char newl = '\n';
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
vector<T> ts(n);
for(size_t i=0;i<n;i++) cin>>ts[i];
return ts;
}
//INSERT ABOVE HERE
signed solve(){
Int n,a,w,k;
cin>>n>>a>>w>>k;
if(n==1){
cout<<a<<newl;
return 0;
}
if(n==k and w>0){
// cout<<"A"<<newl;
Int d=w/n,m=w%n;
Int need=d*(d+1)/2*n+(d+1)*m+(k-1);
auto floor=[&](Int x,Int y){
if(x>=0) return x/y; // -> all WA canceled
return -((-x+(y-1))/y);
};
cout<<floor(a-need,n)<<newl;
return 0;
}
Int ans=-2;
if(n-k+1<=w) chmax(ans,-1);
if(k-1<=a) chmax(ans,0);
if(ans<-1){
cout<<":("<<newl;
return 0;
}
if(ans==-1){
cout<<ans<<newl;
return 0;
}
// x >= 0
// (x + 1) * (k - 1) + x <= a
// x * k + k - x - 1 + x <= a
// x * k <= a - (k - 1)
// x <= (a - (k - 1)) / k
cout<< (a - (k - 1)) / k << newl;
return 0;
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
Int T;
cin>>T;
while(T--) solve();
return 0;
}
beet