# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
389835 | 2021-04-14T15:28:00 Z | ogibogi2004 | Pinball (JOI14_pinball) | C++14 | 28 ms | 460 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].row>v[j+1].row) { return 0; } } for(int j=i+1;j<v.size();j++) { if(v[j].row>v[j-1].row) { 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 204 KB | Output is correct |
4 | Correct | 7 ms | 204 KB | Output is correct |
5 | Correct | 28 ms | 332 KB | Output is correct |
6 | Correct | 2 ms | 204 KB | Output is correct |
7 | Correct | 8 ms | 460 KB | Output is correct |
8 | Correct | 6 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 204 KB | Output is correct |
4 | Correct | 7 ms | 204 KB | Output is correct |
5 | Correct | 28 ms | 332 KB | Output is correct |
6 | Correct | 2 ms | 204 KB | Output is correct |
7 | Correct | 8 ms | 460 KB | Output is correct |
8 | Correct | 6 ms | 332 KB | Output is correct |
9 | Incorrect | 1 ms | 204 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 204 KB | Output is correct |
4 | Correct | 7 ms | 204 KB | Output is correct |
5 | Correct | 28 ms | 332 KB | Output is correct |
6 | Correct | 2 ms | 204 KB | Output is correct |
7 | Correct | 8 ms | 460 KB | Output is correct |
8 | Correct | 6 ms | 332 KB | Output is correct |
9 | Incorrect | 1 ms | 204 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 204 KB | Output is correct |
4 | Correct | 7 ms | 204 KB | Output is correct |
5 | Correct | 28 ms | 332 KB | Output is correct |
6 | Correct | 2 ms | 204 KB | Output is correct |
7 | Correct | 8 ms | 460 KB | Output is correct |
8 | Correct | 6 ms | 332 KB | Output is correct |
9 | Incorrect | 1 ms | 204 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |