답안 #198572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198572 2020-01-26T16:45:10 Z arnold518 Long Distance Coach (JOI17_coach) C++14
0 / 100
7 ms 4984 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;

struct Data
{
	ll D, C;
	bool operator < (const Data &p) { return D<p.D; }
};

int N, M;
ll X, W, T, S[MAXN+10], dp[MAXN+10];
Data A[MAXN+10];
vector<pll> V[MAXN+10];

int main()
{
	int i, j;

	scanf("%lld%d%d%lld%lld", &X, &N, &M, &W, &T);
	for(i=1; i<=N; i++) scanf("%lld", &S[i]); S[N+1]=X;
	for(i=1; i<=M; i++) scanf("%lld%lld", &A[i].D, &A[i].C);
	sort(A+1, A+M+1);
	
	for(i=1; i<=N; i++)
	{
		ll l, r;
		if(S[i-1]/T==S[i]/T)
		{
			l=S[i-1]%T, r=S[i]%T;
			l=lower_bound(A+1, A+M+1, (Data){l, 0})-A;
			r=lower_bound(A+1, A+M+1, (Data){r, 0})-A-1;
		}
		else
		{
			l=0, r=S[i]%T;
			l=lower_bound(A+1, A+M+1, (Data){l, 0})-A;
			r=lower_bound(A+1, A+M+1, (Data){r, 0})-A-1;
		}
		if(l<=r) V[r].push_back({l, S[i]/T});
	}

	dp[0]=(X/T+1)*W;
	for(i=1; i<=M; i++)
	{
		if(A[i].D<=X%T) dp[i]=dp[i-1]+(X/T+1)*W;
		else dp[i]=dp[i-1]+X/T*W;

		for(auto it : V[i])
		{
			ll s=0;
			for(j=i; j>=it.first; j--)
			{
				s+=A[j].C+W*it.second;
				dp[i]=min(dp[i], dp[j-1]+s);
			}
		}
	}
	printf("%lld", dp[M]);
}

Compilation message

coach.cpp: In function 'int main()':
coach.cpp:26:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(i=1; i<=N; i++) scanf("%lld", &S[i]); S[N+1]=X;
  ^~~
coach.cpp:26:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(i=1; i<=N; i++) scanf("%lld", &S[i]); S[N+1]=X;
                                            ^
coach.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%d%d%lld%lld", &X, &N, &M, &W, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coach.cpp:26:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf("%lld", &S[i]); S[N+1]=X;
                      ~~~~~^~~~~~~~~~~~~~~
coach.cpp:27:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=M; i++) scanf("%lld%lld", &A[i].D, &A[i].C);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -