結果
| 問題 |
No.3320 yiwiwiy
|
| コンテスト | |
| ユーザー |
こめだわら
|
| 提出日時 | 2025-10-06 17:14:02 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,744 bytes |
| コンパイル時間 | 5,754 ms |
| コンパイル使用メモリ | 462,776 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-10-31 18:54:24 |
| 合計ジャッジ時間 | 10,366 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 73 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
template<class T> T div_floor(T a, T b) { return a / b - ((a ^ b) < 0 && a % b); }
template<class T> T div_ceil(T a, T b) { return a / b + ((a ^ b) > 0 && a % b); }
template <typename T, typename U> inline bool chmin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template <typename T, typename U> inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a){
if (a.empty()) return os;
os << a.front();
for (auto e : a | views::drop(1)){
os << ' ' << e;
}
return os;
}
void dump(auto ...vs){
((cout << vs << ' '), ...) << endl;
}
#include<boost/multiprecision/cpp_int.hpp>
using Bint= boost::multiprecision::cpp_int;
using i128=__int128_t;
void solve() {
ll Y,I,W,A,B;
cin>>Y>>I>>W>>A>>B;
if (W==0){
string ans="";
rep(i,Y){
ans+='y';
}
rep(i,I){
ans+='i';
}
// cout<<ans<<endl;
cout<<0<<endl;
return;
}
ll leftY=Y/2;
ll rightY=Y-leftY;
if (W==1){
ll leftI=I/2;
ll rightI=I-leftI;
string ans="";
rep(i,leftY){
ans+='y';
}
rep(i,leftI){
ans+='i';
}
ans+='w';
rep(i,rightI){
ans+='i';
}
rep(i,rightY){
ans+='y';
}
// cout<<ans<<endl;
cout<<(Bint)leftY*leftI*rightI*rightY*A<<endl;
return;
}
Bint C=A*leftY*rightY;
Bint mv=-1;
ll md=-1;
ll mvl=-1;
rep(d,W){
ll ml=(I-2*d)*W+d*(d+1);
ml/=2*W;
chmax(ml,0);
chmin(ml,I-d);
ll mr=I-ml-d;
// dump(ml,d,mr);
if (ml>=0 and mr>=0){
Bint v=ml*mr*W+mr*W*d+(ml-mr)*d*(d+1)/2+d*(d-1)*(d+1)/6;
v*=C;
if (d>1){
if (ml>0){
v+=(d-1)*B;
}
else{
v+=(d-2)*B;
}
}
if (d==W-1){
if (mr>0){
v+=B;
}
}
if (v>mv){
mv=v;
md=d;
mvl=ml;
}
}
ml++;
mr--;
if (ml>=0 and mr>=0){
Bint v=ml*mr*W+mr*W*d+(ml-mr)*d*(d+1)/2+(d*(d-1)*(d+1))/6;
v*=C;
if (d>1){
if (ml>0){
v+=(d-1)*B;
}
else{
v+=(d-2)*B;
}
}
if (d==W-1){
if (mr>0){
v+=B;
}
}
if (v>mv){
mv=v;
md=d;
mvl=ml;
}
}
}
ll mvr=I-md-mvl;
string ans="";
rep(i,leftY){
ans+='y';
}
rep(i,mvl){
ans+='i';
}
rep(i,md){
ans+='w';
ans+='i';
}
rep(i,W-md){
ans+='w';
}
rep(i,mvr){
ans+='i';
}
rep(i,rightY){
ans+='y';
}
// cout<<ans<<'\n';
cout<<mv<<'\n';
return;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
ll T=1;
cin>>T;
while (T--){
solve();
}
return 0;
}
こめだわら