Submission #1008512

# Submission time Handle Problem Language Result Execution time Memory
1008512 2024-06-26T13:55:49 Z AdamGS Treatment Project (JOI20_treatment) C++17
35 / 100
3000 ms 4944 KB
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18+7;
const int LIM=1e5+7;
pair<pair<ll,ll>,pair<ll,ll>>T[LIM];
ll odl[LIM], odw[LIM];
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    cin >> T[i].nd.st >> T[i].st.st >> T[i].st.nd >> T[i].nd.nd;
    odl[i]=INF;
    if(T[i].st.st==1) {
      odl[i]=min(odl[i], T[i].nd.nd);
    }
  }
  while(true) {
    pair<ll,ll>mi={INF, INF};
    rep(i, m) if(!odw[i]) mi=min(mi, {odl[i], i});
    if(mi.st==INF) break;
    ll o=mi.st, p=mi.nd;
    odw[p]=1;
    rep(i, m) {
      if(T[p].st.nd-T[i].st.st+1>=abs(T[p].nd.st-T[i].nd.st)) {
        odl[i]=min(odl[i], o+T[i].nd.nd);
      }
    }
  }
  ll ans=INF;
  rep(i, m) if(T[i].st.nd==n) ans=min(ans, odl[i]);
  if(ans==INF) ans=-1;
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3035 ms 4944 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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 372 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 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 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 372 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 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 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 74 ms 684 KB Output is correct
21 Correct 69 ms 604 KB Output is correct
22 Correct 98 ms 856 KB Output is correct
23 Correct 32 ms 856 KB Output is correct
24 Correct 92 ms 860 KB Output is correct
25 Correct 58 ms 860 KB Output is correct
26 Correct 52 ms 860 KB Output is correct
27 Correct 45 ms 856 KB Output is correct
28 Correct 85 ms 884 KB Output is correct
29 Correct 51 ms 884 KB Output is correct
30 Correct 2 ms 860 KB Output is correct
31 Correct 2 ms 860 KB Output is correct
32 Correct 118 ms 856 KB Output is correct
33 Correct 97 ms 860 KB Output is correct
34 Correct 76 ms 856 KB Output is correct
35 Correct 107 ms 860 KB Output is correct
36 Correct 83 ms 820 KB Output is correct
37 Correct 71 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3035 ms 4944 KB Time limit exceeded
2 Halted 0 ms 0 KB -