답안 #858767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858767 2023-10-09T07:27:42 Z cig32 Hiring (IOI09_hiring) C++17
0 / 100
180 ms 12372 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
const int MAXN = 3e5 + 10;
const int MOD = 1e9 + 7;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
  int u = uniform_int_distribution<int>(x, y)(rng); return u;
}
int bm(int b, int p) {
  if(p==0) return 1 % MOD;
  int r = bm(b, p >> 1);
  if(p&1) return (((r*r) % MOD) * b) % MOD;
  return (r*r) % MOD;
}
int inv(int b) { 
  return bm(b, MOD-2);
}
int fastlog(int x) {
  return (x == 0 ? -1 : 64 - __builtin_clzll(x) - 1);
}
void printcase(int i) { cout << "Case #" << i << ": "; }
static void run_with_stack_size(void (*func)(void), size_t stsize) {
  char *stack, *send;
  stack = (char *)malloc(stsize);
  send = stack + stsize - 16;
  send = (char *)((uintptr_t)send / 16 * 16);
  asm volatile(
    "mov %%rsp, (%0)\n"
    "mov %0, %%rsp\n"
    :
    : "r"(send));
  func();
  asm volatile("mov (%0), %%rsp\n" : : "r"(send));
  free(stack);
}
bool cmp(pair<pair<int, int>, int> x, pair<pair<int, int>, int> y) {
  return x.first.first * y.first.second < y.first.first * x.first.second;
}
int bit[20202];
void add(int x, int v) {
  for(;x<20202;x+=x&-x)bit[x]+=v;
}
int sum(int x) {
  int s=0;
  for(;x;x-=x&-x)s+=bit[x];
  return s;
}
int bit2[20202];
void add2(int x, int v) {
  for(;x<20202;x+=x&-x)bit2[x]+=v;
}
int sum2(int x) {
  int s=0;
  for(;x;x-=x&-x)s+=bit2[x];
  return s;
}
void solve(int tc) {
  int n, w;
  cin >> n >> w;
  pair<pair<int, int>, int> a[n+1];
  for(int i=1; i<=n; i++) {
    cin >> a[i].first.first >> a[i].first.second;
    a[i].second = i;
  }
  sort(a+1, a+1+n, cmp);
  int ans1 = 0, ans2 = 1e18;
  int id = 0;
  for(int i=1; i<=n; i++) {
    int u = w * a[i].first.second / a[i].first.first;
    add(a[i].first.second, 1);
    add2(a[i].first.second, a[i].first.second);
    int lb = 0, rb = 20000;
    while(lb < rb) {
      int mid = (lb + rb + 1) >> 1;
      if(sum2(mid) <= u) lb = mid;
      else rb = mid - 1;
    }
    int cnt = sum(lb);
    int bruh = (u - sum2(lb)) / (lb + 1);
    bruh = min(bruh, sum(lb + 1) - sum(lb));
    cnt += bruh;
    int amt = sum2(lb) + bruh * (lb + 1);
    if(cnt > ans1) {
      id = i;
      ans1 = cnt;
      ans2 = amt;
    }
    else if(cnt == ans1 && amt < ans2) {
      id = i;
      ans2 = amt;
    }
  }
  cout << ans1 << '\n';
  if(ans1 == 0) return;
}
void uwu() {
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; //cin >> t;
  for(int i=1; i<=t; i++) solve(i);
}
int32_t main() {
  uwu();
}
/*
g++ C.cpp -std=c++17 -O2 -o C
./C < input.txt
*/

Compilation message

hiring.cpp: In function 'void solve(long long int)':
hiring.cpp:69:7: warning: variable 'id' set but not used [-Wunused-but-set-variable]
   69 |   int id = 0;
      |       ^~
hiring.cpp: At global scope:
hiring.cpp:24:13: warning: 'void run_with_stack_size(void (*)(), size_t)' defined but not used [-Wunused-function]
   24 | static void run_with_stack_size(void (*func)(void), size_t stsize) {
      |             ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
3 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
4 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
5 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
6 Incorrect 1 ms 604 KB Unexpected end of file - int32 expected
7 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
8 Incorrect 1 ms 604 KB Unexpected end of file - int32 expected
9 Incorrect 2 ms 860 KB Unexpected end of file - int32 expected
10 Incorrect 2 ms 604 KB Unexpected end of file - int32 expected
11 Incorrect 2 ms 860 KB Unexpected end of file - int32 expected
12 Incorrect 3 ms 600 KB Unexpected end of file - int32 expected
13 Incorrect 4 ms 860 KB Unexpected end of file - int32 expected
14 Incorrect 5 ms 860 KB Unexpected end of file - int32 expected
15 Incorrect 6 ms 1116 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 604 KB Unexpected end of file - int32 expected
2 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
3 Incorrect 0 ms 604 KB Unexpected end of file - int32 expected
4 Incorrect 7 ms 1204 KB Unexpected end of file - int32 expected
5 Incorrect 18 ms 2028 KB Unexpected end of file - int32 expected
6 Incorrect 108 ms 7740 KB Unexpected end of file - int32 expected
7 Incorrect 132 ms 10064 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 3408 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 5204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 164 ms 11320 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 180 ms 12372 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -