이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long
#define L F.F
#define R F.S
#define O S.F
#define P S.S
using namespace std;
ll n, m,xd, arr[1006], res=100000000000, zd;
pair<pair<ll,ll>,pair<ll,ll>> b[100];
char c;
string s;
set<string> f;
int main(){
cin>>m>>n;
xd=1;
for(int i=0; i<m; i++)xd*=2;
for(int i=0; i<m; i++)cin>>b[i].L>>b[i].R>>b[i].O>>b[i].P;
for(int i=0; i<xd; i++){
zd=i;
ll sp=0;ll dm=0;
for(int h=0; h<=n; h++)arr[h]=0;
for(int j=0; j<m; j++){
if(zd%2){
for(int h=b[j].L; h<=b[j].R; h++){
arr[h]=1;
}
arr[b[j].O]=0;
dm+=b[j].P;
}
zd/=2;
//cout<<1;
}
for(int h=1; h<=n; h++){
if(!arr[h])sp++;
}
if(sp<=1)res=min(res, dm);
}
if(res!=100000000000)cout<<res;
else cout<<-1;
return 0;
}
# | 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... |