結果

問題 No.798 コレクション
ユーザー yuji9511yuji9511
提出日時 2019-03-15 22:12:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,077 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 153,064 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 13:42:01
合計ジャッジ時間 2,644 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 6 ms
4,376 KB
testcase_25 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18 + 7)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[2010], B[2010];
    cin >> N;
    rep(i,0,N) cin >> A[i] >> B[i];
    vector<lpair> lp;
    rep(i,0,N) lp.push_back(make_pair(B[i], A[i]));
    sort(lp.begin(), lp.end(), greater<lpair>());
    ll ans = INF;
    ll days = 0;
    days += 2 * N/3;
    ll tada = N/3;
    days += N % 3;
    rep(i,0,N){
        ll tt = 0;
        tt += lp[i].second;
        ll cnt = 0;
        ll idx = 1;
        rep(j,0,N){
            if(cnt < tada && j != i){
                cnt++;
            }else if(j != i){
                tt += lp[j].second + lp[j].first * idx;
                idx++;
            }
        }
        // print(tt);
        ans = min(ans, tt);
    }
    print(ans);

    


 }
0