# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
219379 | ho94949 | Treatment Project (JOI20_treatment) | C++17 | 3089 ms | 3576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXM = 1e5;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
int N, M;
int T[MAXM], L[MAXM], R[MAXM], C[MAXM];
int XL[MAXM], YL[MAXM], XR[MAXM], YR[MAXM];
bool vis[MAXM];
int main()
{
scanf("%d%d", &N, &M);
for(int i=0; i<M; ++i)
{
scanf("%d%d%d%d", T+i, L+i, R+i, C+i);
--L[i]; //L[i] = 0, R[i] = N covers whole
XL[i] = L[i]-T[i], YL[i] = L[i]+T[i];
XR[i] = R[i]-T[i], YR[i] = R[i]+T[i];
}
using pli = pair<long long, int>;
priority_queue<pli, vector<pli>, greater<pli>> Q;
for(int i=0; i<M; ++i)
if(L[i] == 0)
vis[i] = true, Q.emplace((long long)C[i], i);
while(!Q.empty())
{
auto [cost, idx] = Q.top(); Q.pop();
if(R[idx] == N) return printf("%lld\n", cost), 0;
for(int i=0; i<M; ++i)
{
if(vis[i]) continue;
if(XL[i] <= XR[idx] && YL[i] <= YR[idx])
{
vis[i] = true;
Q.emplace(cost+C[i], i);
}
}
}
puts("-1");
}
Compilation message (stderr)
# | 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... |