This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int m,n;
vector<tuple<int,int,int,int> > v;
int odg=-1;
void proveri(string s)
{
int z=-1;
int r=0;
for (int i=0;i<n;i++)
{
int p=i+1;
for (int 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 (int 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>>n>>m;
for (int i=0;i<m;i++)
{
int a,b,c,d;
cin>>a>>b>>c>>d;
v.push_back({a,b,c,d});
}
f("");
cout<<odg<<endl;
return 0;
}
Compilation message (stderr)
pinball.cpp: In function 'void proveri(std::string)':
pinball.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for (int i=0;i<s.size();i++) if (s[i]=='1') r+=get<3>(v[i]);
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |