답안 #955758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955758 2024-03-31T11:55:31 Z vjudge1 Pinball (JOI14_pinball) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;
    cin>>m>>n;
    long long a[m],b[m],c[m],d[m];
    set<long long> s;
    for(long long i=0; i<m; i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;c[i]--;
        for(long long k=a[i]; k<=b[i]; k++)s.insert(k);
    }
    if(s.size()!=n)
    {
        cout<<-1<<endl;
        return 0;
    }
    long long res=long long_MAX;
    long long last[n];

    for(long long mask=0; mask<(1<<m); mask++)
    {
        long long cena=0;
        memset(last,-1,sizeof(last));
        for(long long i=0; i<m; i++)
        {
            if(mask&(1<<i))
            {
                for(long long k=a[i]; k<=b[i]; k++)last[k]=0;
                last[c[i]]=-1;
                cena+=d[i];
            }
        }
        long long cnt=0;
        for(long long i=0; i<n; i++)
        {
            if(last[i]==-1)cnt++;
        }
        if(cnt==1)res=min(res,cena);
    }
    if(res==long long_MAX)res=-1;
    cout<<res<<endl;
    return 0;
}

Compilation message

pinball.cpp: In function 'int main()':
pinball.cpp:17:16: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   17 |     if(s.size()!=n)
      |        ~~~~~~~~^~~
pinball.cpp:22:19: error: expected primary-expression before 'long'
   22 |     long long res=long long_MAX;
      |                   ^~~~
pinball.cpp:45:13: error: expected primary-expression before 'long'
   45 |     if(res==long long_MAX)res=-1;
      |             ^~~~
pinball.cpp:45:13: error: expected ')' before 'long'
   45 |     if(res==long long_MAX)res=-1;
      |       ~     ^~~~
      |             )