Submission #423938

#TimeUsernameProblemLanguageResultExecution timeMemory
423938tqbfjotldTreatment Project (JOI20_treatment)C++14
4 / 100
142 ms17740 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int memo[100005]; vector<pair<pair<int,int>,pair<int,int> > > stuff; bool cmp(pair<pair<int,int>,pair<int,int>> a, pair<pair<int,int>,pair<int,int>> b){ return a.second.first-a.first.first<b.second.first-b.first.first; } int T[100005]; int L[100005]; int R[100005]; int C[100005]; int R_T[100005]; struct node{ int s,e,v; node *l,*r; node (int _s, int _e){ s = _s; e = _e; v = 999999999999999999LL; if (s!=e){ l = new node(s,(s+e)/2); r = new node((s+e)/2+1,e); } } void upd(int pos, int val){ if (s==e){ v = val; return; } if (pos<=(s+e)/2) l->upd(pos,val); else r->upd(pos,val); v = min(l->v,r->v); return ; } int qu(int a, int b){ if (a<=s && e<=b) return v; if (b<=(s+e)/2) return l->qu(a,b); if (a>(s+e)/2) return r->qu(a,b); return min(l->qu(a,b),r->qu(a,b)); } }*root; main(){ int n,m; scanf("%lld%lld",&n,&m); root = new node(0,m); for (int x = 0; x<m; x++){ int t,l,r,c; scanf("%lld%lld%lld%lld",&t,&l,&r,&c); stuff.push_back({{t,l},{r,c}}); } sort(stuff.begin(),stuff.end(),cmp); for (int x = 0; x<m; x++){ T[x] = stuff[x].first.first; L[x] = stuff[x].first.second; R[x] = stuff[x].second.first; C[x] = stuff[x].second.second; R_T[x] = R[x]; } int ans = 999999999999999999LL; for (int x = 0; x<m; x++){ if (L[x]==1){ memo[x] = C[x]; root->upd(x,C[x]); continue; } memo[x] = C[x]; int minv = lower_bound(R_T,R_T+m,L[x]-1)-R_T; memo[x] += root->qu(minv,x); memo[x] = min(memo[x],999999999999999999LL); root->upd(x,memo[x]); } for (int x = 0; x<m; x++){ if (R[x]==n){ ans = min(ans,memo[x]); } //printf("memo %lld = %lld\n",x,memo[x]); } printf("%lld",ans==999999999999999999LL?-1LL:ans); }

Compilation message (stderr)

treatment.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main(){
      | ^~~~
treatment.cpp: In function 'int main()':
treatment.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     scanf("%lld%lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
treatment.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         scanf("%lld%lld%lld%lld",&t,&l,&r,&c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...