답안 #42694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42694 2018-03-02T20:25:14 Z MatheusLealV Semiexpress (JOI17_semiexpress) C++14
18 / 100
2 ms 768 KB
#include <bits/stdc++.h>
#define M 3005
#define int long long
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;

typedef long long ll;

int A, B, C, W, n, m, k, S[M], marca[M], dp[M], cnt, ans;

vector<pii> val;

bool comp (pii a, pii b){

   return (a.s - a.f) < (b.s - b.f);
}

priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(comp);

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);

    cin>>n>>m>>k>>A>>B>>C>>W;
  
  if(n > 350) return 0;

    for(int i = 1; i <= m; i++) cin>>S[i], marca[S[i]] = 1;

    sort(S + 1, S + m + 1);

    for(int i = 1; i <= m; i++)
    {
        if(i == 1) dp[S[i]] = (S[i] - 1)*A;

        else dp[S[i]] = dp[S[1]] + (S[i] - S[1])*B;

        if(i < m) pq.push({S[i], S[i + 1]});
    }

    while(!pq.empty() && cnt < k - m)
    {
    	int l = pq.top().f, r = pq.top().s;

    	pq.pop();

    	if(dp[l] >= W) continue;

    	int best = (W - dp[l])/A + l + 1;

    	if(!(l < best && best < r)) continue;

    	dp[best] = dp[l] + (best - l)*C;

    	cnt ++;

    	//cout<<"ADD "<<best<<"\n";

    	pq.push({l, best});

    	pq.push({best, r});
    }

    for(int i = 1; i <= n; i++)
    {
    	for(int j = 1; j < i; j++)
    	{
    		if(dp[i]) dp[i] = min(dp[i], dp[j] + (i - j)*A);

    		else dp[i] = dp[j] + (i - j)*A;
    	}

    	if(i > 1 && dp[i] <= W) ans ++;

    	//if(dp[i])cout<<i<<" "<<dp[i]<<"\n";
    }

    cout<<ans<<"\n";
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 356 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 1 ms 720 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 356 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 1 ms 720 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 728 KB Output is correct
9 Correct 2 ms 740 KB Output is correct
10 Correct 2 ms 740 KB Output is correct
11 Correct 2 ms 756 KB Output is correct
12 Correct 1 ms 760 KB Output is correct
13 Correct 2 ms 764 KB Output is correct
14 Incorrect 2 ms 768 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 356 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 1 ms 720 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 728 KB Output is correct
9 Correct 2 ms 740 KB Output is correct
10 Correct 2 ms 740 KB Output is correct
11 Correct 2 ms 756 KB Output is correct
12 Correct 1 ms 760 KB Output is correct
13 Correct 2 ms 764 KB Output is correct
14 Incorrect 2 ms 768 KB Output isn't correct
15 Halted 0 ms 0 KB -