Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#pragma GCC optimize("03")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <cstdio>
- #include <string>
- #include <vector>
- #include <map>
- #include <set>
- #include <unordered_map>
- #include <unordered_set>
- #include <queue>
- #include <deque>
- #include <cmath>
- #include <numeric>
- #include <algorithm>
- #include <ctime>
- #include <chrono>
- #include <random>
- #include <functional>
- #include <stack>
- //#include <windows.h>
- //void* operator new(size_t size) {
- // if (void* ptr = HeapAlloc(GetProcessHeap(), 0, size ? size : 1)) return ptr;
- // throw std::bad_alloc{};
- //}
- //void operator delete(void* ptr) {
- // HeapFree(GetProcessHeap(), 0, ptr);
- //}
- using namespace std;
- using ll = long long;
- using db = double;
- using ldb = long double;
- using pii = pair<int, int>;
- using pll = pair<ll, ll>;
- using vint = vector<int>;
- using vll = vector<ll>;
- using vst = vector<string>;
- #define all(x) x.begin(), x.end()
- #define size(x) int(x.size())
- #define rep(x) for(int rep_i = 0; rep_i < x; ++rep_i)
- #define forp(i, s, f) for(int i = s; i < f; ++i)
- #define form(i, s, f) for(int i = s; i > f; --i)
- #define PB push_back
- #define MP make_pair
- #define F first
- #define S second
- #define elif else if
- #define dprint(x) for (auto now: x) cout << now << " "
- const int MOD = 1e9 + 7;
- const int MOD2 = 998244353;
- const int INF = 2e9 + 7;
- const ll LINF = 1e18 + 7;
- const double EPS = 1e-9;
- const long double PI = acosl(-1.0);
- void solve() {
- int n, k;
- cin >> n >> k;
- vector<vll> sp(n, vll(3));
- forp(i, 0, n) cin >> sp[i][0];
- forp(i, 0, n) cin >> sp[i][1];
- forp(i, 0, n) sp[i][2] = (ll)i + 1;
- ldb l = 0, r = INF;
- vector<pair<ldb, int>> spp(n), ans;
- forp(j, 0, 100) {
- ldb m = l + (r - l) / 2;
- forp(i, 0, n) {
- spp[i].first = sp[i][0] - sp[i][1] * m;
- spp[i].second = sp[i][2];
- }
- sort(all(spp));
- reverse(all(spp));
- ldb sm = 0;
- forp(i, 0, k) {
- sm += spp[i].first;
- }
- if (sm <= 0) {
- l = m;
- }
- else {
- r = m;
- }
- }
- ldb c = r;
- forp(i, 0, n) {
- spp[i].first = sp[i][0] - sp[i][1] * c;
- spp[i].second = sp[i][2];
- }
- sort(all(spp));
- reverse(all(spp));
- cout << l << ' ' << r << '\n';
- forp(i, 0, k) {
- cout << spp[i].second << '\n';
- }
- }
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- /*cout << setprecision(x)*/
- cout << fixed;
- int t;
- t = 1;
- while (t > 0) {
- solve();
- t--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement