Submission #600915

# Submission time Handle Problem Language Result Execution time Memory
600915 2022-07-21T09:08:30 Z 장태환(#8468) Long Distance Coach (JOI17_coach) C++17
16 / 100
1 ms 852 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[2010];
int X,N,M,W,T;
vector<pair<int,int>>x;
vector<int>arr;
vector<pair<pair<int,int>,int>>t;
int cnt[2020];
int psum[2020][2020];
vector<int>exc[2020];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >>X>>N>>M>>W>>T;
    int i;
    for(i=0;i<N;i++)
    {
        int a;
        cin >>a;
        arr.push_back(a);
    }
    arr.push_back(X);
    int ans=0;
    for(i=0;i<M;i++)
    {
        int a,b;
        cin >>a>>b;
        x.push_back({a,b});
        ans+=(X/T+((X%T)>=a))*W;
    }
    ans+=(X/T+1)*W;
    sort(x.begin(),x.end());
    sort(arr.begin(),arr.end());
    for(i=0;i<arr.size();i++)
    {
        int s=0;
        pair<int,int>tt={arr[i]%T,0};
        if(arr[i]%T==0)
            tt.first=T;
        int e=lower_bound(x.begin(),x.end(),tt)-x.begin()-1;
        if(e!=x.size()-1)
        {
            if(x[e+1].first==arr[i]%T)
                exc[e+1].push_back(arr[i]/T);
        }
        if(arr[i]%T==0)
            ans-=W;
        if(i&&arr[i-1]/M==arr[i]/M)
        {
            tt={(arr[i-1])%T+1,0LL};
            s=lower_bound(x.begin(),x.end(),tt)-x.begin();
        }
        if(s<=e)
        {

            t.push_back({{s,e},(arr[i]-1)/T});
        }
    }
    memset(dp,-90,sizeof(dp));
    dp[x.size()]=0;
    for(i=0;i<x.size();i++)
    {
        cnt[i]=(X/T+((X%T)>=x[i].first));
        int j;
        for(j=0;j<t.size();j++)
        {
            if(t[j].first.first<=i&&t[j].first.second>=i)
            {
                psum[i][j]=-x[i].second+(cnt[i]-t[j].second-(exc[i].end()-lower_bound(exc[i].begin(),exc[i].end(),t[j].second)))*W;
            }
        }
    }
    int  j;
    for(i=(int)x.size()-1;i>=0;i--)
    {
        for(j=0;j<t.size();j++)
        {
            psum[i][j]+=psum[i+1][j];
        }
    }
    for(i=(int)x.size()-1;i>=0;i--)
    {
        dp[i]=dp[i+1];
        for(j=0;j<t.size();j++)
        {
            if(t[j].first.first<=i&&t[j].first.second>=i)
                dp[i]=max(dp[i],dp[t[j].first.second+1]+psum[i][j]);
        }
    }
    cout <<ans-dp[0];
}

Compilation message

coach.cpp: In function 'int main()':
coach.cpp:36:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(i=0;i<arr.size();i++)
      |             ~^~~~~~~~~~~
coach.cpp:43:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if(e!=x.size()-1)
      |            ~^~~~~~~~~~~~
coach.cpp:63:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(i=0;i<x.size();i++)
      |             ~^~~~~~~~~
coach.cpp:67:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for(j=0;j<t.size();j++)
      |                 ~^~~~~~~~~
coach.cpp:78:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |         for(j=0;j<t.size();j++)
      |                 ~^~~~~~~~~
coach.cpp:86:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |         for(j=0;j<t.size();j++)
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 852 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 1 ms 852 KB Output is correct
27 Correct 1 ms 852 KB Output is correct
28 Correct 1 ms 852 KB Output is correct
29 Correct 1 ms 852 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 1 ms 852 KB Output is correct
32 Correct 1 ms 852 KB Output is correct
33 Correct 1 ms 852 KB Output is correct
34 Incorrect 1 ms 852 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 852 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 1 ms 852 KB Output is correct
27 Correct 1 ms 852 KB Output is correct
28 Correct 1 ms 852 KB Output is correct
29 Correct 1 ms 852 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 1 ms 852 KB Output is correct
32 Correct 1 ms 852 KB Output is correct
33 Correct 1 ms 852 KB Output is correct
34 Incorrect 1 ms 852 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 852 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 1 ms 852 KB Output is correct
27 Correct 1 ms 852 KB Output is correct
28 Correct 1 ms 852 KB Output is correct
29 Correct 1 ms 852 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 1 ms 852 KB Output is correct
32 Correct 1 ms 852 KB Output is correct
33 Correct 1 ms 852 KB Output is correct
34 Incorrect 1 ms 852 KB Output isn't correct
35 Halted 0 ms 0 KB -