結果

問題 No.2078 魔抜けなパープル
ユーザー _yurimoir_yurimoir
提出日時 2022-10-06 22:31:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 596 bytes
コンパイル時間 1,617 ms
コンパイル使用メモリ 172,668 KB
実行使用メモリ 6,068 KB
最終ジャッジ日時 2023-09-02 02:33:53
合計ジャッジ時間 3,414 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int q;
    cin>>q;
    while(q--){
        int x,a;
        cin>>x>>a;
        vector<pair<double,ll>> tank(a);
        for(int i=0;i<a;i++){
            tank[i]={(double)(i+1)+(double)x/(i+1),(ll)i+1};
        }
        sort(tank.rbegin(),tank.rend());
        int pos=a-1;
        ll mp=0;
        while(a){
            while(a<tank[pos].second&&pos>=0)pos--;
            a-=tank[pos].second;
            mp+=(tank[pos].second)*(tank[pos].second)+x;
            pos--;
        }
        cout<<mp<<endl;
    }
}
0