Submission #963723

# Submission time Handle Problem Language Result Execution time Memory
963723 2024-04-15T14:18:46 Z Soumya1 Treatment Project (JOI20_treatment) C++17
35 / 100
3000 ms 5968 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
void testCase() {
  int n, m;
  cin >> n >> m;
  vector<int> t(m), l(m), r(m), c(m);
  for (int i = 0; i < m; i++) cin >> t[i] >> l[i] >> r[i] >> c[i];
  priority_queue<pair<ll, int>> pq;
  vector<bool> vis(m);
  vector<ll> dist(m, inf);
  for (int i = 0; i < m; i++) {
    if (l[i] == 1) {
      dist[i] = c[i];
      pq.push({-dist[i], i});
    }
  }
  while (!pq.empty()) {
    auto [_, u] = pq.top();
    pq.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (int i = 0; i < m; i++) {
      if (t[i] < t[u]) {
        if (r[u] >= l[i] + t[u] - t[i] - 1 && dist[i] > dist[u] + c[i]) {
          dist[i] = dist[u] + c[i];
          pq.push({-dist[i], i});
        }
      } else {
        if (l[i] <= r[u] - t[i] + t[u] + 1 && dist[i] > dist[u] + c[i]) {
          dist[i] = dist[u] + c[i];
          pq.push({-dist[i], i});
        }
      }
    }
  }
  ll ans = inf;
  for (int i = 0; i < m; i++) {
    if (r[i] == n) ans = min(ans, dist[i]);
  }
  cout << (ans == inf ? -1 : ans) << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  testCase();
  return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3021 ms 5968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 456 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 452 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 456 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 92 ms 860 KB Output is correct
21 Correct 92 ms 728 KB Output is correct
22 Correct 71 ms 736 KB Output is correct
23 Correct 44 ms 604 KB Output is correct
24 Correct 81 ms 896 KB Output is correct
25 Correct 51 ms 600 KB Output is correct
26 Correct 53 ms 604 KB Output is correct
27 Correct 45 ms 604 KB Output is correct
28 Correct 81 ms 872 KB Output is correct
29 Correct 43 ms 756 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 177 ms 860 KB Output is correct
33 Correct 137 ms 964 KB Output is correct
34 Correct 147 ms 748 KB Output is correct
35 Correct 169 ms 928 KB Output is correct
36 Correct 138 ms 856 KB Output is correct
37 Correct 150 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3021 ms 5968 KB Time limit exceeded
2 Halted 0 ms 0 KB -