Submission #1094372

#TimeUsernameProblemLanguageResultExecution timeMemory
1094372thangdz2k7Treatment Project (JOI20_treatment)C++17
100 / 100
76 ms10824 KiB
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using li = pair <ll, int>; using vi = vector <int>; const int N = 1e5 + 5; const int mod = 1e9 + 7; const ll inf = 1e18; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} struct project{ int t, l, r, c; bool operator < (project other){ return l - t < other.l - other.t; } } p[N]; int NN, m; ll d[N], Min[4 * N]; void build(int s = 1, int l = 1, int r = m){ if (l == r){ Min[s] = p[l].l + p[l].t; return; } int mid = l + r >> 1; build(s << 1, l, mid); build(s << 1 | 1, mid + 1, r); Min[s] = min(Min[s << 1], Min[s << 1 | 1]); } priority_queue <li, vector <li>, greater <li>> qu; void get(int u, int v, ll k, int s = 1, int l = 1, int r = m){ if (p[l].l - p[l].t > u || Min[s] > v) return; if (l == r){ if (d[l] == inf){ d[l] = k + p[l].c; qu.push({d[l], l}); } Min[s] = inf; return; } int mid = l + r >> 1; get(u, v, k, s << 1, l, mid); get(u, v, k, s << 1 | 1, mid + 1, r); Min[s] = min(Min[s << 1], Min[s << 1 | 1]); } void solve(){ cin >> NN >> m; for (int i = 1; i <= m; ++ i){ cin >> p[i].t >> p[i].l >> p[i].r >> p[i].c; d[i] = inf; } sort(p + 1, p + m + 1); build(); for (int i = 1; i <= m; ++ i) if (p[i].l == 1){ d[i] = p[i].c; qu.push({d[i], i}); } while (qu.size()){ auto [du, u] = qu.top(); qu.pop(); get(p[u].r - p[u].t + 1, p[u].r + p[u].t + 1, du); } ll ans = inf; for (int i = 1; i <= m; ++ i) if (p[i].r == NN) minl(ans, d[i]); if (ans == inf) cout << -1; else cout << ans; } int main(){ if (fopen("pqh.inp", "r")){ freopen("pqh.inp", "r", stdin); freopen("pqh.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t --) solve(); return 0; }

Compilation message (stderr)

treatment.cpp:20:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
treatment.cpp:20:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
treatment.cpp:21:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   21 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
treatment.cpp:21:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   21 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
treatment.cpp: In function 'void build(int, int, int)':
treatment.cpp:40:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |     int mid = l + r >> 1;
      |               ~~^~~
treatment.cpp: In function 'void get(int, int, ll, int, int, int)':
treatment.cpp:58:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   58 |     int mid = l + r >> 1;
      |               ~~^~~
treatment.cpp: In function 'int main()':
treatment.cpp:89:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
treatment.cpp:90:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   90 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...