#include #include #include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin>>n; vector a(n),b(n); for(int i = 0;i>a[i]>>b[i]; int buy = 0; { int res = n; while(res>0){ buy++; res--; if(buy%2==0) res--; } } vector> dp(n+1,vector(buy+1,1e18)); dp[0][0] = 0; vector idx(n); for(int i = 0;i b[j]; }); for(int i = 0;i