Submission #567938

# Submission time Handle Problem Language Result Execution time Memory
567938 2022-05-24T11:30:13 Z BadPenalty New Home (APIO18_new_home) C++14
0 / 100
5000 ms 18676 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
const int N = 1e6,mod = 1e9+7;
ll X[N];
ll A[N];
ll B[N];
ll K[N];
ll ans[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,q,k;
    cin>>n>>k>>q;
    for(int i = 0;i<n;i++)
    {
        cin>>X[i];
        cin>>K[i];
        cin>>A[i];
        cin>>B[i];
    }
    while(q--)
    {
        int x,t;
        cin>>x>>t;
        for(int i = 1;i<=k;i++)
            ans[i] = 1e9;
        for(int i = 0;i<n;i++)
        {
            if(A[i]<=t&&B[i]>=t)
            {
                ans[K[i]] = min(ans[K[i]],abs(x-X[i]));
            }
        }
        int out = 0;
        for(int i = 1;i<=k;i++)
            out+=ans[i];
        if(out>=1e9)
            out = -1;
        cout<<out<<endl;
    }
    return 0;
}
/*

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5058 ms 18676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5043 ms 17604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -