#include <bits/stdc++.h>
using namespace std;
long long m,n;
vector<tuple<long long,long long,long long,long long> > v;
long long odg=-1;
void proveri(string s)
{
long long z=-1;
long long r=0;
for (long long i=0;i<n;i++)
{
long long p=i+1;
for (long long j=0;j<m;j++)
{
if (s[j]=='1' && p>=get<0>(v[j]) && p<=get<1>(v[j]))
p=get<2>(v[j]);
}
if (i==0) z=p;
if (z!=p) return;
}
for (long long i=0;i<s.size();i++) if (s[i]=='1') r+=get<3>(v[i]);
if (odg==-1) odg=r;
else odg=min(odg,r);
}
void f(string s)
{
if (s.size()==v.size())
{
proveri(s);
return;
}
f(s+"0");
f(s+"1");
}
int main()
{
cin>>m>>n;
for (long long i=0;i<m;i++)
{
long long a,b,c,d;
cin>>a>>b>>c>>d;
v.push_back({a,b,c,d});
}
f("");
cout<<odg<<endl;
return 0;
}
Compilation message
pinball.cpp: In function 'void proveri(std::string)':
pinball.cpp:25:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (long long i=0;i<s.size();i++) if (s[i]=='1') r+=get<3>(v[i]);
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
11 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
11 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1102 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
11 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1102 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
11 ms |
348 KB |
Output is correct |
9 |
Execution timed out |
1102 ms |
348 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |