# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
955790 |
2024-03-31T12:23:39 Z |
vjudge1 |
Pinball (JOI14_pinball) |
C++17 |
|
1000 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
class Q{
public:
long long int l, r, vo, den;
Q(long long int o, long long int d, long long int v, long long int de): l(o), r(d), vo(v), den(de){}
};
int main()
{
long long int m, n;
cin>>m>>n;
vector<Q>a;
for(long long int i=0; i<m; i++)
{
long long int aa, bb, cc, dd;
cin>>aa>>bb>>cc>>dd;
aa--;
bb--;
cc--;
a.push_back(Q(aa, bb, cc, dd));
}
long long int minn=LLONG_MAX;
for(long long int i=0; i<pow(2, m); i++)
{
vector<long long int>comb;
for(long long int j=0; j<m; j++)
{
if(i&(1<<j))
{
comb.push_back(j);
}
}
/*cout<<"kombinbacija\n";
for(int j=0; j<comb.size(); j++)
cout<<comb[j]<<" ";
cout<<endl;*/
bool first=true, kiki=true;
long long int kraj=-1, local_min=INT_MIN;
//bool visited[comb.size()]={};
for(long long int w=0; w<n; w++)
{
long long int curr=w, pari=0;
for(long long int j=0; j<comb.size(); j++)
{
pari+=a[comb[j]].den;
if(a[comb[j]].l<=curr && curr<=a[comb[j]].r)
{
curr=a[comb[j]].vo;
/*if(!visited[j])
{
visited[j]=1;
}*/
}
}
if(first==true)
{
kraj=curr;
first=false;
}
else
{
if(kraj!=curr)
{
kiki=0;
break;
}
else
{
if(pari>local_min)
local_min=pari;
}
}
}
if(kiki)
{
if(local_min<minn)
minn=local_min;
}
//cout<<endl<<local_min<<endl<<"-------------\n";
}
if(minn==LLONG_MAX)
cout<<-1;
else
cout<<minn;
return 0;
}
Compilation message
pinball.cpp: In function 'int main()':
pinball.cpp:44:37: 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]
44 | for(long long int j=0; j<comb.size(); j++)
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1045 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1045 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1045 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |