제출 #1065027

#제출 시각아이디문제언어결과실행 시간메모리
1065027anangoJobs (BOI24_jobs)C++17
0 / 100
6 ms14684 KiB
// // Created by adavy on 8/18/2024. // #include <bits/stdc++.h> //#pragma GCC optimize("O3") using namespace std; using ll = long long; const ll MOD = 1e9 + 7; //#define int ll #define f first #define s second /* pair<ll,ll> merge(pair<ll,ll> a, pair<ll,ll> b){ return {min(a.f,b.f),a.s-max(a.f,b.f)+b.s}; } struct prs{ set<pair<ll,ll>> ps; void insert(pair<ll,ll> p){ cout << "ps: " << endl; for(auto& itm:ps){ cout << itm.f << " " << itm.s << endl; } cout << "p: " << p.f << " " << p.s << endl; while(1){ auto it = ps.lower_bound(p); if (it != ps.end()) { if (it-> f <= p.s){ p = merge(p,*it); ps.erase(it); continue; } } auto it2 = ps.upper_bound(p); if (it2 != ps.begin()){ --it2; if (it2->s >= p.f){ p = merge(p,*it2); ps.erase(it2); continue; } } if (p.f > p.s){ ps.clear(); return; } ps.insert(p); break; } } void subtract(ll x){ ll balance = -x; ll neg = balance; while (!ps.empty() && balance < 0){ balance -= ps.begin()->f; neg = min(neg,balance); balance += ps.begin()->s; ps.erase(ps.begin()); } if (balance >= 0){ this->insert({-neg,balance-neg}); } } }; vector<int> val; vector<prs> sets; vector<int> which; */ vector<vector<int>> adj; void dfs(int v, int p){ cout << "v: " << v << endl; //int maxsz = -1, maxch = -1; for(int u:adj[v]){ if (u == p) continue; dfs(u,v); } } signed main(){ std::ios::sync_with_stdio(false); cin.tie(NULL); int N,s; cin >> N >> s; adj.resize(N+5); for(int i=1;i<=N;++i){ ll x,p; cin >> x >> p; //val[i] = x; adj[p].push_back(i); adj[i].push_back(p); } dfs(0,-1); //int t = s; /* for(auto& item:sets[which[0]].ps){ if (t >= item.f){ t -= item.f; t += item.s; } }*/ //cout << t-s << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...