Submission #577535

#TimeUsernameProblemLanguageResultExecution timeMemory
577535balbitTreatment Project (JOI20_treatment)C++14
0 / 100
3068 ms8380 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll, ll> #define f first #define s second #define SZ(x) (int)((x).size()) #define ALL(x) (x).begin(), (x).end() #define pb push_back #define MX(a,b) a = max(a,b) #define MN(a,b) a = min(a,b) #define FOR(i,a,b) for (int i = a; i<b; ++i) #define REP(i,n) for (int i = 0; i<n; ++i) #define REP1(i,n) for (int i = 1; i<=n; ++i) #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<"- "<<#__VA_ARGS__<<": ", _do(__VA_ARGS__) template<typename T> void _do(T && x){cerr<<x<<endl;} template<typename T, typename ...S> void _do(T && x, S && ...y){cerr<<x<<", "; _do(y...);} #else #define bug(...) #define endl '\n' #endif // BALBIT const int maxn = 3e5+5; const int mod = 1e9+7; const ll inf = 0x3f3f3f3f3f3f3f3f; struct rect{ int x,y,r,c,i; bool operator < (rect &R) { if (y != R.y) return y < R.y; return x < R.x; } }; bool isbeg[maxn], isend[maxn]; // for each rectangle, is it the beg or end????? ll get(vector<rect> v) { for (rect &R : v) { bug(R.x,R.y,R.r,R.c,R.i); bug(isbeg[R.i]); bug(isend[R.i]); } sort(ALL(v)); vector<ll> dp(SZ(v), inf); ll re = inf; REP(i, SZ(v)) { if (isbeg[v[i].i]) { dp[i] = v[i].c; } else REP(j,i) { if (v[j].y + v[j].r + 1 >= v[i].y && v[j].x + v[j].r + 1 >= v[i].x ) { MN(dp[i], dp[j] + v[i].c); } } if (isend[v[i].i]) { MN(re, dp[i]); } } if (re == inf) re = -1; return re; } signed main(){ ios::sync_with_stdio(0), cin.tie(0); bug(1,2); vector<rect> go; int n,m; cin>>n>>m; REP(i,m) { int t,l,r,c; cin>>t>>l>>r>>c; --l; --r; isbeg[i] = l == 0; isend[i] = r == n-1; go.pb({l+t, l-t,r-l,c,i}); } ll re =get(go); cout<<re<<endl; }

Compilation message (stderr)

treatment.cpp: In function 'long long int get(std::vector<rect>)':
treatment.cpp:45:16: warning: unused variable 'R' [-Wunused-variable]
   45 |     for (rect &R : v) {
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...