# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
293600 |
2020-09-08T08:27:58 Z |
phillip |
Pinball (JOI14_pinball) |
C++14 |
|
2 ms |
3072 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[29][109][109];
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++)
{
mp[v[i]]=i;
}
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<n;i++)
{
//cout<<ans<<"\n";
ans=min(ans,bt(m-1,i,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++)
| ~^~~~~~~~~
pinball.cpp:42:17: warning: unused variable 'j' [-Wunused-variable]
42 | for(int i=0,j=0;i<v.size();i++)
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3072 KB |
Output is correct |
2 |
Incorrect |
2 ms |
3072 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3072 KB |
Output is correct |
2 |
Incorrect |
2 ms |
3072 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3072 KB |
Output is correct |
2 |
Incorrect |
2 ms |
3072 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3072 KB |
Output is correct |
2 |
Incorrect |
2 ms |
3072 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |