結果

問題 No.664 超能力者Aと株価予測
ユーザー どららどらら
提出日時 2018-03-10 10:00:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,245 bytes
コンパイル時間 1,979 ms
コンパイル使用メモリ 178,656 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 22:30:27
合計ジャッジ時間 2,704 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,944 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 diff;
  int s, e;
};
bool operator<(const ST& a, const ST& b){
  if(a.diff == b.diff) return a.s < b.s;
  return a.diff > b.diff;
}

int main(){
  int N, M;
  ll K;
  cin >> N >> M >> K;
  vector<ll> v;
  rep(i,N+1){
    ll a;
    cin >> a;
    v.push_back(a);
  }


  vector<ST> w;
  rep(i,v.size()){
    REP(j,i+1,v.size()){
      w.push_back((ST){v[j]-v[i],i,j});
    }
  }
  sort(ALLOF(w));

  vector<pair<int,int>> ret;
  vector<int> memo(N+10,0);
  rep(i,w.size()){
    if(w[i].diff <= 0) continue;
    bool ok = true;
    REP(j,w[i].s,w[i].e+1){
      if(memo[j] == 1) ok = false;
    }
    if(ok && M>0){
      ret.push_back(make_pair(w[i].s, w[i].e));
      REP(j,w[i].s,w[i].e+1){
        memo[j] = 1;
      }
      M--;
    }
  }

  sort(ALLOF(ret));

  rep(i,ret.size()){
    ll a = v[ret[i].first];
    ll b = v[ret[i].second];
    ll x = K/a;
    K -= x*a;
    K += x*b;
  }
  cout << K << endl;
  
  return 0;
}
0