# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
389815 | 2021-04-14T14:47:23 Z | ogibogi2004 | Pinball (JOI14_pinball) | C++14 | 1000 ms | 8860 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long const ll INF=2e15; const int MAXM=1e5+6; struct device { ll row,a,b,c,d; bool operator<(device const& other)const { return c<other.c; } }; device d[MAXM]; int n,m; bool check(int mask) { if(mask==0)return 0; vector<device>v; int maxj=-1; for(int j=0;j<m;j++) { if(mask&(1<<j)){v.push_back(d[j+2]);maxj=j+2;} } sort(v.begin(),v.end()); for(int i=0;i<v.size();i++) { if(v[i].row==maxj) { for(int j=i-1;j>=0;j--) { if(v[j].c>v[j+1].c) { return 0; } } for(int j=i+1;j<v.size();j++) { if(v[j].c<v[j-1].c) { return 0; } } } } return 1; } int main() { cin>>m>>n; for(int i=2;i<m+2;i++) { d[i].row=i; cin>>d[i].a>>d[i].b>>d[i].c>>d[i].d; } ll ans=INF; for(int mask=0;mask<(1<<m);mask++) { if(!check(mask))continue; set<int>s; for(int i=1;i<=n;i++) { int u=i; for(int j=2;j<m+2;j++) { if(mask&(1<<(j-2))) { if(d[j].a<=u&&d[j].b>=u) { u=d[j].c; } } } s.insert(u); } if(s.size()>1) { continue; } ll sum=0; for(int j=2;j<m+2;j++) { if(mask&(1<<(j-2))) { sum+=d[j].d; } } if(sum<ans)ans=sum; } if(ans==INF)cout<<"-1\n"; else cout<<ans<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 7 ms | 300 KB | Output is correct |
4 | Correct | 16 ms | 324 KB | Output is correct |
5 | Correct | 47 ms | 332 KB | Output is correct |
6 | Correct | 4 ms | 204 KB | Output is correct |
7 | Correct | 30 ms | 336 KB | Output is correct |
8 | Correct | 22 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 7 ms | 300 KB | Output is correct |
4 | Correct | 16 ms | 324 KB | Output is correct |
5 | Correct | 47 ms | 332 KB | Output is correct |
6 | Correct | 4 ms | 204 KB | Output is correct |
7 | Correct | 30 ms | 336 KB | Output is correct |
8 | Correct | 22 ms | 332 KB | Output is correct |
9 | Execution timed out | 1068 ms | 8860 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 7 ms | 300 KB | Output is correct |
4 | Correct | 16 ms | 324 KB | Output is correct |
5 | Correct | 47 ms | 332 KB | Output is correct |
6 | Correct | 4 ms | 204 KB | Output is correct |
7 | Correct | 30 ms | 336 KB | Output is correct |
8 | Correct | 22 ms | 332 KB | Output is correct |
9 | Execution timed out | 1068 ms | 8860 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 7 ms | 300 KB | Output is correct |
4 | Correct | 16 ms | 324 KB | Output is correct |
5 | Correct | 47 ms | 332 KB | Output is correct |
6 | Correct | 4 ms | 204 KB | Output is correct |
7 | Correct | 30 ms | 336 KB | Output is correct |
8 | Correct | 22 ms | 332 KB | Output is correct |
9 | Execution timed out | 1068 ms | 8860 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |