답안 #431810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431810 2021-06-17T15:42:04 Z lyc Long Distance Coach (JOI17_coach) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
typedef pair<ll,ll> pll;

const int mxN = 2e5+5;
const int mxM = 2e5+5;

ll X, T, S[mxN];
int N, M, W;
pll cus[mxM];

int fst[mxN], lst[mxN];
ll base, dp[mxM];

bool dead[9];

ll cntless(ll a, ll b) {
    return b > a ? 0 : (a-b+T-1)/T;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> X >> N >> M >> W >> T;
    FOR(i,1,N) cin >> S[i];
    sort(S+1,S+1+N);
    S[0] = 1; S[N+1] = X;
    FOR(i,1,M){
        ll D, C; cin >> D >> C;
        cus[i] = pll(D,C);
    }

    ll ans = LLONG_MAX;
    FOR(i,0,(1<<M)-1){
        ll cur = W;
        memset(dead,0,sizeof dead);
        FOR(j,0,N){
            ll die = T;
            cur += (S[j+1]/T - S[j]/T) * W;
            FOR(k,1,M) if (!dead[k]) {
                if ((i&(1<<(k-1))) == 0) {
                    die = min(die,cus[k].first);
                }
                cur += (cntless(S[j+1],cus[k].first) - cntless(S[j],cus[k].first)) * W;
            }
            FOR(k,1,M) if (!dead[k] && cus[k].first >= die && cus[k].first < S[j+1]%T) {
                dead[k] = 1;
                cur += cus[k].second;
                cur -= W;
            }
        }
        //TRACE(i _ cur);
        ans = min(ans,cur);
    }

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