結果
| 問題 | No.3537 Thank You! |
| コンテスト | |
| ユーザー |
Tehom
|
| 提出日時 | 2026-05-08 22:45:34 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 1,461 bytes |
| 記録 | |
| コンパイル時間 | 3,110 ms |
| コンパイル使用メモリ | 281,536 KB |
| 実行使用メモリ | 9,884 KB |
| 最終ジャッジ日時 | 2026-05-08 22:45:42 |
| 合計ジャッジ時間 | 5,448 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サブタスク1 | 30 % | AC * 21 |
| サブタスク2 | 70 % | AC * 15 |
| 合計 | 2.5 * 100% = 250 点 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
template <typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;} return false;}
template <typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;} return false;}
ll op(ll a,ll b){return a+b;}
ll e(){return 0;}
ll target;
bool f(ll x){return x<=target;}
void solve(){
int n; cin >> n;
ll b; cin >> b;
segtree<ll,op,e> sg(n),cnt(n);
vector<pair<ll,ll>> p(n);
rep(i,0,n) cin >> p[i].first;
rep(i,0,n) cin >> p[i].second;
sort(all(p));
rep(i,0,n) sg.set(i,p[i].first*p[i].second);
rep(i,0,n) cnt.set(i,p[i].second);
ll ans=0;
rep(i,0,n){
if(p[i].second>=b){
chmax(ans,b);
}
else{
ll tmp=p[i].second;
target=b-p[i].second;
sg.set(i,0);
cnt.set(i,0);
int r=sg.max_right<f>(0);
if(r == n){
tmp+=cnt.prod(0,r);
chmax(ans,tmp);
}
else{
tmp+=cnt.prod(0,r);
tmp+=(target-sg.prod(0,r))/p[r].first;
chmax(ans,tmp);
}
sg.set(i,p[i].first*p[i].second);
cnt.set(i,p[i].second);
}
}
cout << ans << "\n";
return;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T=1;
// cin >> T;
while(T--) solve();
}
Tehom