Submission #955782

#TimeUsernameProblemLanguageResultExecution timeMemory
955782vjudge1Pinball (JOI14_pinball)C++17
0 / 100
2 ms348 KiB
#include <bits/stdc++.h> #define long long int using namespace std; class Q{ public: int l, r, vo, den; Q(int o, int d, int v, int de): l(o), r(d), vo(v), den(de){} }; int main() { int m, n; cin>>m>>n; vector<Q>a; for(int i=0; i<m; i++) { int aa, bb, cc, dd; cin>>aa>>bb>>cc>>dd; aa--; bb--; cc--; a.push_back(Q(aa, bb, cc, dd)); } int minn=INT_MAX; for(int i=0; i<pow(2, m); i++) { vector<int>comb; for(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; int kraj=-1, local_min=INT_MIN; //bool visited[comb.size()]={}; for(int w=0; w<n; w++) { int curr=w, pari=0; for(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==INT_MAX) cout<<-1; else cout<<minn; return 0; }

Compilation message (stderr)

pinball.cpp: In function 'int main()':
pinball.cpp:45:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             for(int j=0; j<comb.size(); j++)
      |                          ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...