結果
| 問題 |
No.664 超能力者Aと株価予測
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2018-03-10 10:00:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,245 bytes |
| コンパイル時間 | 1,982 ms |
| コンパイル使用メモリ | 182,068 KB |
| 実行使用メモリ | 5,584 KB |
| 最終ジャッジ日時 | 2024-10-12 20:54:30 |
| 合計ジャッジ時間 | 2,494 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 8 |
ソースコード
#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;
}
どらら