Submission #293582

# Submission time Handle Problem Language Result Execution time Memory
293582 2020-09-08T08:20:26 Z phillip Pinball (JOI14_pinball) C++14
0 / 100
298 ms 524292 KB
#include <bits/stdc++.h>
#define ll long long
#define fast cin.tie(0);cout.tie(0);
#define order ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);
#define pb push_back
using namespace std;
int n,m,a[200009],b[200009],c[200009];
ll d[200009],ans;
ll mxv=1e9;
ll dp[209][609][609];
ll bt(int x,int l,int r)
{
    if(x==-1)
    {
        if(l==0&&r==n)return 0;
        else return mxv;
    }
    if(dp[x][l][r]!=-1)return dp[x][l][r];
    ll &ret=dp[x][l][r];
    ret=mxv;
    ret=bt(x-1,l,r);
    if(l<=c[x]&&c[x]<=r)ret=min(ret,d[x]+bt(x-1,min(l,a[x]),max(r,b[x])));
    return ret;
}
vector<int>v;
map<int,int>mp;
int main()
{
    fast order
    mxv*=mxv;
    cin>>m>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<m;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
    for(int i=0;i<m;i++)
    {
        v.push_back(a[i]);
        v.push_back(b[i]);
        v.push_back(c[i]);
    }
    v.push_back(n);
    sort(v.begin(),v.end());
    for(int i=0,j=0;i<v.size();i++)
    {
        int x=v[i];
        if(i)
        {
            if(x==v[i-1])continue;
        }
        mp[v[i]]=j;
        j++;
    }
    for(int i=0;i<m;i++)
    {
        a[i]=mp[a[i]];
        b[i]=mp[b[i]];
        c[i]=mp[c[i]];
    }
    n=mp[n];
    ans=mxv;
    for(int i=0;i<m;i++)
    {
        //cout<<ans<<"\n";
        ans=min(ans,bt(i-1,a[i],b[i])+d[i]);
    }
    if(ans==mxv)cout<<-1;
    else cout<<ans;
}

Compilation message

pinball.cpp: In function 'int main()':
pinball.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i=0,j=0;i<v.size();i++)
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 298 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 298 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 298 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 298 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -