답안 #165128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165128 2019-11-25T08:49:57 Z cbertram Semiexpress (JOI17_semiexpress) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i = a; i < b; i++)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll N, M, K;
  cin >> N;
  cin >> M;
  cin >> K;
  ll A, B, C;
  cin >> A;
  cin >> B;
  cin >> C;
  ll T;
  cin >> T;
  vll S(M+1);
  rep(m,0,M) cin >> S[m];
  rep(m,0,M+1) S[m]--;
  S[M] = S[M-1]+1;

  ll sum = 0;
  priority_queue<pair<ll, pll>> pq;
  rep(m,0,M) {
    ll reach = (T-B*S[m])/A;
    if(T < B*S[m]) break;
    sum += min(S[m+1]-S[m], 1+reach);
    if(S[m]+reach+1 < S[m+1] && T >= B*S[m]+C*(reach+1))
      pq.push(make_pair(1+(T-B*S[m]-C*(reach+1))/A , make_pair(S[m]+reach+1, m)));
  }
  ll k = K-M;
  while(!pq.empty() && k > 0) {
    auto top = pq.top();
    pq.pop();
    sum += min(S[top.second.second+1]-top.second.first, top.first);
    //cout << "S: " << top.second.first << '\n';
    k--;
    ll nextpos = top.second.first+top.first;
    if(nextpos < S[top.second.second+1] && T >= B*S[top.second.second]+C*(nextpos-S[top.second.second])) {
      pq.push(make_pair(min(S[top.second.second]-nextpos, 1+(T-B*S[top.second.second]-C*(nextpos-S[top.second.second]))/A),
			make_pair(nextpos, top.second.second)));
    }
  }

  cout << sum-1 << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -