제출 #1249893

#제출 시각아이디문제언어결과실행 시간메모리
1249893M_SH_OGym Badges (NOI22_gymbadges)C++20
42 / 100
2093 ms19788 KiB
#include <bits/stdc++.h> #define ll long long #define ll1 long long #define ull unsigned long long #define dou long double #define str string #define vll vector<ll> #define vi vector<int> #define pll pair<ll, ll> #define vpll vector<pll> #define vbool vector<bool> #define vstr vector<str> #define vvll vector<vll> #define pb push_back #define pf push_front //#define endl "\n" #define fr first #define se second // #define sortcmp(a) sort(a.begin(), a.end(), cmp) #define sort(a) sort(a.begin(), a.end()) #define reverse(a) reverse(a.begin(), a.end()) #define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define INF 1000000000000000000 #define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> using namespace std; //using namespace __gnu_pbds; mt19937 rng(time(0)); ll randll(ll l, ll r){ return uniform_int_distribution<ll>(l, r)(rng); } int main(){ speed; ll n; cin >> n; vpll a(n); vector<pll> b; for(int i = 0; i < n; i ++){ cin >> a[i].fr; } for(int i = 0; i < n; i ++){ cin >> a[i].se; b.pb({a[i].se+a[i].fr, i}); } sort(b); vll dp(n+7, INF); dp[0] = 0; for(int i = 1; i <= n; i ++){ ll k = b[i-1].se; //cout << a[k].fr << ' ' << a[k].se << endl; for(int j = n-1; j >= 0; j --){ if(dp[j] <= a[k].se) dp[j+1] = min(dp[j+1], dp[j]+a[k].fr); } /*for(int j = 0; j <= n; j ++){ cout << dp[j] << ' '; } cout << endl;*/ } for(int i = n; i >= 0; i --){ if(dp[i] != INF){ cout << i << endl; 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...