답안 #1113345

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113345 2024-11-16T12:10:30 Z epicci23 커다란 상품 (IOI17_prize) C++17
20 / 100
195 ms 1536 KB
#include "bits/stdc++.h"
#include "prize.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;

const int S = 100;
const int S2 = 20;

int suf = -1;
vector<int> Cache={-1,-1};
map<int,vector<int>> dp;

vector<int> Ask(int i){
  if(dp.count(i)) return dp[i];
  return dp[i]=ask(i);
}

int ask_all(int l,int r){
  for(int i=l;i<=r;i++){
    vector<int> x = Ask(i);
    if(x[0]+x[1]==0) return i;
    if(x[1]==suf) Cache=x;
    else suf--;
  }
  return -23;
}

int Learn(int l,int r){
  if(l>r) return -1;
  if(l==r){
    auto u = Ask(l);
    if(u[0]+u[1]==0) return l;
    if(u[1]==suf) Cache=u;
    else suf--;
    return -1;
  }
  int BL = (int)sqrtl(r-l+1);
  auto u = Ask(l+BL);
  if(u[0]+u[1]==0) return l+BL;
  if(u[1]==suf) return Learn(l+BL+1,r);
  int lf = Learn(l,l+BL-1);
  if(lf!=-1) return lf;
  if(u[0]+u[1]!=Cache[0]+Cache[1]) suf--;
  return Learn(l+BL+1,r);
}

int find_best(int n){
  if(n<=1000) return ask_all(0,n-1);
  for(int i=0;i<=500;i++){
    vector<int> x = Ask(i);
    if(x[0]+x[1]==0) return i;
    if(x[0]+x[1]>=Cache[0]+Cache[1]){
      Cache=x;
      suf=Cache[1];
    }
    else suf--;
  }
  return Learn(501,n-1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 488 KB Output is correct
2 Correct 16 ms 336 KB Output is correct
3 Correct 12 ms 592 KB Output is correct
4 Correct 23 ms 592 KB Output is correct
5 Correct 13 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 13 ms 336 KB Output is correct
8 Correct 13 ms 428 KB Output is correct
9 Correct 12 ms 336 KB Output is correct
10 Correct 22 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 592 KB Output is correct
2 Correct 14 ms 784 KB Output is correct
3 Correct 17 ms 440 KB Output is correct
4 Correct 25 ms 600 KB Output is correct
5 Correct 14 ms 592 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 12 ms 1004 KB Output is correct
8 Correct 11 ms 336 KB Output is correct
9 Correct 13 ms 592 KB Output is correct
10 Correct 22 ms 840 KB Output is correct
11 Correct 26 ms 592 KB Output is correct
12 Correct 8 ms 592 KB Output is correct
13 Correct 38 ms 1252 KB Output is correct
14 Correct 15 ms 592 KB Output is correct
15 Correct 67 ms 804 KB Output is correct
16 Incorrect 195 ms 1536 KB Incorrect
17 Halted 0 ms 0 KB -