Submission #710462

# Submission time Handle Problem Language Result Execution time Memory
710462 2023-03-15T08:57:41 Z groshi Hotel (CEOI11_hot) C++17
40 / 100
4000 ms 32156 KB
#include<iostream>
#define int long long
using namespace std;
int t[600000][2];
int mam[600000][2];
int32_t main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n,m,o,x,y,z;
    cin>>n>>m>>o;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        t[i][0]=x;
        t[i][1]=y;
    }
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        mam[i][0]=x;
        mam[i][1]=y;
    }
    int wynik=0;
    for(int i=1;i<=o;i++)
    {
        int maxx=0;
        int gdzie1=0;
        int gdzie2=0;
        for(int a=1;a<=m;a++)
        {
            if(mam[a][0]==-1)
                continue;
            int maxx1=0;
            int gdzie=0;
            for(int b=1;b<=n;b++)
            {
                if(mam[a][1]>t[b][1])
                    continue;
                if(t[b][0]==-1)
                    continue;
                if(mam[a][0]-t[b][0]>maxx1)
                {
                    gdzie=b;
                    maxx1=mam[a][0]-t[b][0];
                }
            }
            if(maxx1>maxx)
            {
                maxx=maxx1;
                gdzie1=gdzie;
                gdzie2=a;
            }
        }
        wynik+=maxx;
        t[gdzie1][0]=-1;
        mam[gdzie2][0]=-1;
    }
    cout<<wynik;
    return 0;
}

Compilation message

hot.cpp: In function 'int32_t main()':
hot.cpp:11:19: warning: unused variable 'z' [-Wunused-variable]
   11 |     int n,m,o,x,y,z;
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4098 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4042 ms 3020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4006 ms 5100 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4024 ms 14176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4005 ms 28256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4034 ms 32156 KB Time limit exceeded
2 Halted 0 ms 0 KB -