結果

問題 No.798 コレクション
ユーザー どららどらら
提出日時 2019-03-15 23:15:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,359 bytes
コンパイル時間 1,773 ms
コンパイル使用メモリ 178,412 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 14:11:37
合計ジャッジ時間 3,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 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 1 ms
4,376 KB
testcase_24 AC 35 ms
4,376 KB
testcase_25 AC 37 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  ll val;
  ll A, B;
  int i;
};
bool operator<(const ST& a, const ST& b){
  if(a.val == b.val) return a.B < b.B;
  return a.val > b.val;
}

priority_queue<ST> que[2005];
bool checked[2005];

int main(){
  int N;
  cin >> N;

  int M = 0;
  {
    vector<int> tmp(N,0);
    int j = N-1;
    rep(d,N){
      if(tmp[d] == -1) break;
      M++;
      if(d%2 == 1){
        tmp[j] = -1;
        j--;
      }
    }
  }

  vector<ST> v;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    v.push_back((ST){0LL,a,b,i});
  }

  rep(i,N-M){
    ll d = M+i;
    vector<ST> w;
    rep(j,v.size()){
      ST tmp = v[j];
      tmp.val = tmp.A + d * tmp.B;
      w.push_back(tmp);
    }
    sort(ALLOF(w));
    rep(j,w.size()){
      if(checked[w[j].i]) continue;
      checked[w[j].i] = true;
      break;
    }
  }

  ll ret = 0;
  vector<ll> bs;
  rep(i,N){
    if(checked[i]) continue;
    bs.push_back(v[i].B);
    ret += v[i].A;
  }
  sort(ALLOF(bs));
  reverse(ALLOF(bs));
  rep(i,bs.size()){
    ret += i * bs[i];
  }

  cout << ret << endl;
  return 0;
}

0