結果

問題 No.3537 Thank You!
コンテスト
ユーザー nauclhlt
提出日時 2026-03-07 17:49:54
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,065 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,672 ms
コンパイル使用メモリ 220,320 KB
実行使用メモリ 10,828 KB
最終ジャッジ日時 2026-05-08 20:55:14
合計ジャッジ時間 8,063 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
サブタスク1 30 % AC * 21
サブタスク2 70 % TLE * 1 -- * 14
合計 2.5 * 30% = 75 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    ll B;
    cin >> B;
    vector<ll> C(N);
    vector<ll> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }

    ll ans = 0;

    for (int i = 0; i < N; i++)
    {
        vector<pair<ll, ll>> cards;
        for (int j = 0; j < N; j++)
        {
            if (j == i)
            {
                cards.emplace_back(1, S[i]);
            }
            else
            {
                cards.emplace_back(C[j], S[j]);
            }
        }

        sort(cards.begin(), cards.end());

        ll bought = 0;
        ll money = B;

        for (int j = 0; j < cards.size(); j++)
        {
            ll count = min(cards[j].second, money / cards[j].first);
            money -= count * cards[j].first;
            bought += count;
        }

        ans = max(ans, bought);
    }

    cout << ans << endl;
}
0