제출 #1179694

#제출 시각아이디문제언어결과실행 시간메모리
1179694InvMODLong Distance Coach (JOI17_coach)C++17
71 / 100
2093 ms9796 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define gcd __gcd #define sz(v) (int) v.size() #define pb push_back #define pi pair<int,int> #define all(v) (v).begin(), (v).end() #define compact(v) (v).erase(unique(all(v)), (v).end()) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define ROF(i, a, b) for(int i = (a); i >= (b); i--) #define dbg(x) "[" #x " = " << (x) << "]" #define int long long using ll = long long; using ld = long double; using ull = unsigned long long; template<typename T> bool ckmx(T& a, const T& b){if(a < b) return a = b, true; return false;} template<typename T> bool ckmn(T& a, const T& b){if(a > b) return a = b, true; return false;} const int N = 2e5+5; const ll MOD = 1e9+7; const ll INF = 1e18; /* Erase passenger i: + Erase all passenger j that has (D(j) > D(i)) and (D(j) + k * T at some position x that has (S(x) % D > D(i)) + If there is no position that has (S(x) % D > D(i)) then we can't delete passenger i :c */ void solve() { ll X; int n,m,W,T; cin >> X >> n >> m >> W >> T; vector<int> S(n + 2), D(m + 1), C(m + 1); FOR(i, 1, n) cin >> S[i]; S[n + 1] = X; FOR(i, 1, m) cin >> D[i] >> C[i]; vector<int> idx(m + 1); iota(all(idx), 0); sort(1 + all(idx), [&](int x, int y){ return D[x] % T > D[y] % T; }); ll total = (X / T) + 1; FOR(i, 1, m) total += (X / T) + (X % T >= D[i]); total = total * W; vector<ll> cost(n + 2), dp(m + 1, 0); FOR(i, 1, m){ int x = idx[i]; FOR(j, 1, n + 1){ if(S[j] % T > D[x]){ cost[j] = cost[j] + ((X / T) + (X % T >= D[x]) - (S[j] / T)) * W - C[x]; FOR(k, 1, i - 1){ if(D[idx[k]] > S[j] % T) dp[i] = max(dp[i], dp[k] + cost[j]); } } } dp[i] = max(dp[i], *max_element(all(cost))); } cout << total - *max_element(all(dp)) << "\n"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "InvMOD" if(fopen(name".INP", "r")){ freopen(name".INP","r",stdin); freopen(name".OUT","w",stdout); } int t = 1; //cin >> t; while(t--) solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

coach.cpp: In function 'int main()':
coach.cpp:83:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |         freopen(name".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
coach.cpp:84:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         freopen(name".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...