답안 #298508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298508 2020-09-13T03:37:04 Z mohammedehab2002 Long Distance Coach (JOI17_coach) C++11
71 / 100
2000 ms 11864 KB
#include <bits/stdc++.h>
using namespace std;
pair<long long,int> d[200005];
long long x,t,s[200005],dp[200005],fs[200005];
int f[200005];
int main()
{
	int n,m,w;
	scanf("%lld%d%d%d%lld",&x,&n,&m,&w,&t);
	for (int i=0;i<n;i++)
	scanf("%lld",&s[i]);
	s[n]=x;
	sort(s,s+n+1);
	for (int i=1;i<=m;i++)
	scanf("%lld%d",&d[i].first,&d[i].second);
	sort(d,d+m+1);
	memset(f,-1,sizeof(f));
	for (int i=n;i>=0;i--)
	{
		int p=upper_bound(d,d+m+1,make_pair(s[i]%t,0))-d-1;
		f[p]=i;
	}
	dp[m+1]=(x/t+1)*w;
	fs[m+1]=dp[m+1];
	for (int i=m;i>0;i--)
	{
		fs[i]=min(((x-d[i].first)/t+1)*w+dp[i+1],(long long)2e18);
		dp[i]=fs[i];
		long long mn=2e18;
		for (int j=i+1;j<=m+1;j++)
		{
			if (f[j-1]!=-1)
			mn=min(mn,((s[f[j-1]]-d[i].first)/t)*w);
			fs[j]=min((long long)2e18,fs[j]+mn+d[i].second);
			dp[i]=min(dp[i],fs[j]);
		}
	}
	printf("%lld",dp[1]);
}

Compilation message

coach.cpp: In function 'int main()':
coach.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%lld%d%d%d%lld",&x,&n,&m,&w,&t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coach.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  scanf("%lld",&s[i]);
      |  ~~~~~^~~~~~~~~~~~~~
coach.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |  scanf("%lld%d",&d[i].first,&d[i].second);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1152 KB Output is correct
9 Correct 1 ms 1280 KB Output is correct
10 Correct 1 ms 1152 KB Output is correct
11 Correct 1 ms 1152 KB Output is correct
12 Correct 1 ms 1152 KB Output is correct
13 Correct 1 ms 1152 KB Output is correct
14 Correct 1 ms 1152 KB Output is correct
15 Correct 1 ms 1152 KB Output is correct
16 Correct 1 ms 1152 KB Output is correct
17 Correct 1 ms 1152 KB Output is correct
18 Correct 1 ms 1152 KB Output is correct
19 Correct 1 ms 1152 KB Output is correct
20 Correct 1 ms 1152 KB Output is correct
21 Correct 1 ms 1280 KB Output is correct
22 Correct 1 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1152 KB Output is correct
9 Correct 1 ms 1280 KB Output is correct
10 Correct 1 ms 1152 KB Output is correct
11 Correct 1 ms 1152 KB Output is correct
12 Correct 1 ms 1152 KB Output is correct
13 Correct 1 ms 1152 KB Output is correct
14 Correct 1 ms 1152 KB Output is correct
15 Correct 1 ms 1152 KB Output is correct
16 Correct 1 ms 1152 KB Output is correct
17 Correct 1 ms 1152 KB Output is correct
18 Correct 1 ms 1152 KB Output is correct
19 Correct 1 ms 1152 KB Output is correct
20 Correct 1 ms 1152 KB Output is correct
21 Correct 1 ms 1280 KB Output is correct
22 Correct 1 ms 1152 KB Output is correct
23 Correct 1 ms 1152 KB Output is correct
24 Correct 2 ms 1152 KB Output is correct
25 Correct 1 ms 1152 KB Output is correct
26 Correct 1 ms 1152 KB Output is correct
27 Correct 1 ms 1152 KB Output is correct
28 Correct 1 ms 1152 KB Output is correct
29 Correct 1 ms 1152 KB Output is correct
30 Correct 1 ms 1152 KB Output is correct
31 Correct 1 ms 1152 KB Output is correct
32 Correct 1 ms 1152 KB Output is correct
33 Correct 1 ms 1152 KB Output is correct
34 Correct 1 ms 1152 KB Output is correct
35 Correct 1 ms 1152 KB Output is correct
36 Correct 1 ms 1152 KB Output is correct
37 Correct 1 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1152 KB Output is correct
9 Correct 1 ms 1280 KB Output is correct
10 Correct 1 ms 1152 KB Output is correct
11 Correct 1 ms 1152 KB Output is correct
12 Correct 1 ms 1152 KB Output is correct
13 Correct 1 ms 1152 KB Output is correct
14 Correct 1 ms 1152 KB Output is correct
15 Correct 1 ms 1152 KB Output is correct
16 Correct 1 ms 1152 KB Output is correct
17 Correct 1 ms 1152 KB Output is correct
18 Correct 1 ms 1152 KB Output is correct
19 Correct 1 ms 1152 KB Output is correct
20 Correct 1 ms 1152 KB Output is correct
21 Correct 1 ms 1280 KB Output is correct
22 Correct 1 ms 1152 KB Output is correct
23 Correct 1 ms 1152 KB Output is correct
24 Correct 2 ms 1152 KB Output is correct
25 Correct 1 ms 1152 KB Output is correct
26 Correct 1 ms 1152 KB Output is correct
27 Correct 1 ms 1152 KB Output is correct
28 Correct 1 ms 1152 KB Output is correct
29 Correct 1 ms 1152 KB Output is correct
30 Correct 1 ms 1152 KB Output is correct
31 Correct 1 ms 1152 KB Output is correct
32 Correct 1 ms 1152 KB Output is correct
33 Correct 1 ms 1152 KB Output is correct
34 Correct 1 ms 1152 KB Output is correct
35 Correct 1 ms 1152 KB Output is correct
36 Correct 1 ms 1152 KB Output is correct
37 Correct 1 ms 1152 KB Output is correct
38 Correct 11 ms 1280 KB Output is correct
39 Correct 18 ms 1280 KB Output is correct
40 Correct 23 ms 1280 KB Output is correct
41 Correct 11 ms 1280 KB Output is correct
42 Correct 11 ms 1280 KB Output is correct
43 Correct 10 ms 1280 KB Output is correct
44 Correct 15 ms 1280 KB Output is correct
45 Correct 11 ms 1280 KB Output is correct
46 Correct 16 ms 1280 KB Output is correct
47 Correct 18 ms 1280 KB Output is correct
48 Correct 13 ms 1408 KB Output is correct
49 Correct 12 ms 1280 KB Output is correct
50 Correct 11 ms 1280 KB Output is correct
51 Correct 11 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 1152 KB Output is correct
6 Correct 1 ms 1152 KB Output is correct
7 Correct 1 ms 1152 KB Output is correct
8 Correct 1 ms 1152 KB Output is correct
9 Correct 1 ms 1280 KB Output is correct
10 Correct 1 ms 1152 KB Output is correct
11 Correct 1 ms 1152 KB Output is correct
12 Correct 1 ms 1152 KB Output is correct
13 Correct 1 ms 1152 KB Output is correct
14 Correct 1 ms 1152 KB Output is correct
15 Correct 1 ms 1152 KB Output is correct
16 Correct 1 ms 1152 KB Output is correct
17 Correct 1 ms 1152 KB Output is correct
18 Correct 1 ms 1152 KB Output is correct
19 Correct 1 ms 1152 KB Output is correct
20 Correct 1 ms 1152 KB Output is correct
21 Correct 1 ms 1280 KB Output is correct
22 Correct 1 ms 1152 KB Output is correct
23 Correct 1 ms 1152 KB Output is correct
24 Correct 2 ms 1152 KB Output is correct
25 Correct 1 ms 1152 KB Output is correct
26 Correct 1 ms 1152 KB Output is correct
27 Correct 1 ms 1152 KB Output is correct
28 Correct 1 ms 1152 KB Output is correct
29 Correct 1 ms 1152 KB Output is correct
30 Correct 1 ms 1152 KB Output is correct
31 Correct 1 ms 1152 KB Output is correct
32 Correct 1 ms 1152 KB Output is correct
33 Correct 1 ms 1152 KB Output is correct
34 Correct 1 ms 1152 KB Output is correct
35 Correct 1 ms 1152 KB Output is correct
36 Correct 1 ms 1152 KB Output is correct
37 Correct 1 ms 1152 KB Output is correct
38 Correct 11 ms 1280 KB Output is correct
39 Correct 18 ms 1280 KB Output is correct
40 Correct 23 ms 1280 KB Output is correct
41 Correct 11 ms 1280 KB Output is correct
42 Correct 11 ms 1280 KB Output is correct
43 Correct 10 ms 1280 KB Output is correct
44 Correct 15 ms 1280 KB Output is correct
45 Correct 11 ms 1280 KB Output is correct
46 Correct 16 ms 1280 KB Output is correct
47 Correct 18 ms 1280 KB Output is correct
48 Correct 13 ms 1408 KB Output is correct
49 Correct 12 ms 1280 KB Output is correct
50 Correct 11 ms 1280 KB Output is correct
51 Correct 11 ms 1280 KB Output is correct
52 Execution timed out 2065 ms 11864 KB Time limit exceeded
53 Halted 0 ms 0 KB -