제출 #1052991

#제출 시각아이디문제언어결과실행 시간메모리
1052991vjudge1Jobs (BOI24_jobs)C++17
0 / 100
42 ms11976 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define append push_back #define add insert #define nl '\n' #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll,ll> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define terminator main #define N 300001 ll x[N]; ll y[N]; int par[N]; void solve(){ ll n,m,s; cin>>n>>s; vector<pll> v; for(int i=1;i<=n;i++){ cin>>m>>par[i]; if(x[par[i]]<0){ y[i]=max(y[par[i]],-x[par[i]]-m); x[i]=x[par[i]]+m; } else{ x[i]=m; y[i]=max(-m,y[par[i]]); } if(x[i]>0) v.append({y[i],x[i]}); } sort(all(v)); for(auto& i:v){ if(i.ff>s) break; s+=i.ss; } cout<<s; } int terminator(){ L0TA; solve(); return 0; }
#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...