답안 #584390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584390 2022-06-27T10:22:59 Z Mr_Husanboy Pinball (JOI14_pinball) C++14
11 / 100
1000 ms 47388 KB
// Muallif: Mansuraliyev Husanboy Murotali o'g'li  >> NamPS
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long 
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(a) a.begin(), a.end()
#define F first
#define rep(x,start,end) for(int x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define S second
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define vii vector<int>
#define vll vector<ll>
// 0-9 >> 48-57;    A-Z>>65-90   and   a-z>>97-122 respectively;
int n,m;

struct dev{
	int a,b,c,d;
};

bool check(vector<dev> v){
	vector<bool> rem(n+1);
	int cnt=0;
	set<int> st;
	for(int i=1;i<=n;i++){
		int cur=i;
		for(dev u:v){
			if(u.a<=cur&&cur<=u.b) cur=u.c;
		}
		st.insert(cur);
	}
	return st.size()==1;
}

void solve(){
	cin>>m>>n;
	vector<dev> a(m);
	for(int i=0;i<m;i++){
		cin>>a[i].a>>a[i].b>>a[i].c>>a[i].d;
	}ll ans=1e18;
	for(int i=0;i<(1<<m);i++){
		vector<dev> v; ll sum=0;
		for(int j=0;j<m;j++){
			if(i&(1<<j)) v.push_back(a[j]),sum+=a[j].d;
		}
		if(check(v)) ans=min(ans,sum);
	}
	cout<<(ans==1e18?-1:ans);
}
 
int main(){
	ios;
//	int t; cin>>t; while(t--)
	solve();
}

Compilation message

pinball.cpp: In function 'bool check(std::vector<dev>)':
pinball.cpp:27:6: warning: unused variable 'cnt' [-Wunused-variable]
   27 |  int cnt=0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 328 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 31 ms 340 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 17 ms 360 KB Output is correct
8 Correct 10 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 328 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 31 ms 340 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 17 ms 360 KB Output is correct
8 Correct 10 ms 360 KB Output is correct
9 Execution timed out 1089 ms 47388 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 328 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 31 ms 340 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 17 ms 360 KB Output is correct
8 Correct 10 ms 360 KB Output is correct
9 Execution timed out 1089 ms 47388 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 328 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 31 ms 340 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 17 ms 360 KB Output is correct
8 Correct 10 ms 360 KB Output is correct
9 Execution timed out 1089 ms 47388 KB Time limit exceeded
10 Halted 0 ms 0 KB -