제출 #49366

#제출 시각아이디문제언어결과실행 시간메모리
49366SpaimaCarpatilorLong Distance Coach (JOI17_coach)C++17
0 / 100
3 ms520 KiB
#include<bits/stdc++.h> using namespace std; int N, M, W, T, how[200009]; long long X, dp[200009], need[200009]; const long long INF = 1LL << 60; pair < int, long long > station[200009]; pair < long long, int > passenger[200009]; void read () { scanf ("%lld %d %d %d %d", &X, &N, &M, &W, &T); for (int i=1; i<=N; i++) scanf ("%lld", &station[i].second), station[i].first = station[i].second % T; if (X % T != 0) station[++N] = {X % T, X}; sort (station + 1, station + N + 1); for (int i=1; i<=M; i++) scanf ("%d %d", &passenger[i].first, &passenger[i].second); sort (passenger + 1, passenger + M + 1); } int main () { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); read (); for (int i=1; i<=M; i++) need[i] = 1LL * W * ((X - passenger[i].first) / T + 1); for (int i=0; i<=M; i++) dp[i] = INF; dp[M + 1] = 1LL * W * (X / T + 1);///dp[i] = i gets there (in our case the driver) and I've already considered all those with higher residuum passenger[M + 1].first = T + 1; for (int i=M + 1; i>=1; i--) { if (dp[i] + need[i - 1] < dp[i - 1]) dp[i - 1] = dp[i] + need[i - 1], how[i - 1] = i; int pntr = N + 1; long long fastestAbort = X + 1; /*while (pntr > 1 && station[pntr - 1].first > passenger[i].first) pntr --; without this, the source should be wrong*/ ///I want to ignore those starting at pntr cause they would all abort i as well long long curr = dp[i]; for (int j=i - 1; j>=1; j--) { ///assume you've aborted all passengers in range [j, i - 1] while (pntr > 1 && station[pntr - 1].first > passenger[j].first) pntr --, fastestAbort = min (fastestAbort, station[pntr].second); if (station[pntr].first <= passenger[j].first || station[pntr].first > passenger[i].first) break; curr += passenger[j].second; if (fastestAbort > passenger[j].first) curr += 1LL * W * ((fastestAbort - passenger[j].first) / T); if (curr + need[j - 1] < dp[j - 1]) dp[j - 1] = curr + need[j - 1], how[j - 1] = i; } } printf ("%lld\n", dp[0]); return 0; }

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

coach.cpp: In function 'void read()':
coach.cpp:20:66: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf ("%d %d", &passenger[i].first, &passenger[i].second);
                         ~~~~~~~~~~~~~~~~~~~                      ^
coach.cpp:13:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%lld %d %d %d %d", &X, &N, &M, &W, &T);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coach.cpp:15:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%lld", &station[i].second), station[i].first = station[i].second % T;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coach.cpp:20:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d %d", &passenger[i].first, &passenger[i].second);
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...