Submission #1065704

# Submission time Handle Problem Language Result Execution time Memory
1065704 2024-08-19T11:06:56 Z Unforgettablepl Long Distance Coach (JOI17_coach) C++17
71 / 100
2000 ms 18600 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int X,N,M,W,T;
    cin >> X >> N >> M >> W >> T;
    vector<tuple<int,int,int>> arr;
    arr.emplace_back(0,0,0);
    int iterations = X/T;
    X%=T;
    arr.emplace_back(X,2,iterations);
    for(int i=1;i<=N;i++) {
        int S;cin>>S;
        arr.emplace_back(S%T,2,S/T);
    }
    for(int i=1;i<=M;i++) {
        int D,C;cin>>D>>C;
        arr.emplace_back(D,1,C);
    }
    sort(arr.begin(), arr.end());
    vector<int> DP(arr.size());
    DP[0] = (iterations+1)*W;
    for(int i=1;i<arr.size();i++) {
        auto [pos,type,c] = arr[i];
        if(type==1) {
            if(pos<X)DP[i]=(iterations+1)*W + DP[i-1];
            else DP[i]=iterations*W + DP[i-1];
            continue;
        }
        DP[i]=DP[i-1];
        int mini = c;
        int offset = 0;
        for(int j=i-1;j;j--) {
            if(get<1>(arr[j])!=1) {
                mini = min(mini,get<2>(arr[j]));
                if(mini<c)break;
                continue;
            }
            offset+=get<2>(arr[j])+mini*W;
            DP[i]=min(DP[i],DP[j-1]+offset);
        }
    }
    cout << DP.back() << '\n';
}

Compilation message

coach.cpp: In function 'int32_t main()':
coach.cpp:28:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=1;i<arr.size();i++) {
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 452 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 452 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 452 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 7 ms 604 KB Output is correct
42 Correct 8 ms 600 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 8 ms 700 KB Output is correct
45 Correct 8 ms 600 KB Output is correct
46 Correct 1 ms 604 KB Output is correct
47 Correct 1 ms 604 KB Output is correct
48 Correct 1 ms 656 KB Output is correct
49 Correct 7 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 1 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 452 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 7 ms 604 KB Output is correct
42 Correct 8 ms 600 KB Output is correct
43 Correct 5 ms 604 KB Output is correct
44 Correct 8 ms 700 KB Output is correct
45 Correct 8 ms 600 KB Output is correct
46 Correct 1 ms 604 KB Output is correct
47 Correct 1 ms 604 KB Output is correct
48 Correct 1 ms 656 KB Output is correct
49 Correct 7 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 1 ms 644 KB Output is correct
52 Correct 110 ms 18512 KB Output is correct
53 Correct 89 ms 18600 KB Output is correct
54 Execution timed out 2068 ms 17832 KB Time limit exceeded
55 Halted 0 ms 0 KB -