Submission #955754

# Submission time Handle Problem Language Result Execution time Memory
955754 2024-03-31T11:54:14 Z vjudge1 Pinball (JOI14_pinball) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

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

    for(int mask=0; mask<(1<<m); mask++)
    {
        int cena=0;
        memset(last,-1,sizeof(last));
        for(int i=0; i<m; i++)
        {
            if(mask&(1<<i))
            {
                for(int k=a[i]; k<=b[i]; k++)last[k]=0;
                last[c[i]]=-1;
                cena+=d[i];
            }
        }
        int cnt=0;
        for(int i=0; i<n; i++)
        {
            if(last[i]==-1)cnt++;
        }
        if(cnt==1)res=min(res,cena);
    }
    if(res==INT_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<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |     if(s.size()!=n)
      |        ~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -