제출 #1234694

#제출 시각아이디문제언어결과실행 시간메모리
1234694PenguinsAreCuteLong Distance Coach (JOI17_coach)C++17
16 / 100
2 ms328 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long x, t, w; int n, m; cin >> x >> n >> m >> w >> t; long long s[n+1], d[m], c[m]; for(int i=0;i<n;i++) cin >> s[i]; s[n++] = x; for(int i=0;i<m;i++) cin >> d[i] >> c[i]; long long ans = 0; for(int i=0;i<(1<<m);i++) { long long eject[m]; memset(eject,1,sizeof(eject)); for(int j=0;j<n;j++) for(int k=0;k<m;k++) if((i&(1<<k)) && d[k] < (s[j] % t)) { bool ok = 1; for(int l=0;l<m;l++) if((s[j] % t) > d[l] && d[l] > d[k] && !(i & (1 << l))) ok = 0; if(ok) eject[k] = min(eject[k], s[j] - (s[j] % t) + d[k]); } long long cur = 0; for(int j=0;j<m;j++) if(i&(1<<j)) cur += (eject[j] > 1e13 ? 1e17 : c[j] - w * ((x - eject[j]) / t + 1)); ans = min(ans, cur); } ans += w * ((x / t) + 1); for(int i=0;i<m;i++) ans += w * ((x - d[i]) / t + 1); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...