이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
using ll = long long;
const int nmax = 1e5 + 5;
namespace QUERY {
ll v[nmax];
set<int> ind;
ll query(int x) {
if(v[x] == 0) {
v[x] = skim(x);
ind.insert(x);
}
return v[x];
}
}
ll n, k, a, s;
ll fmin(ll x) {
return x * k + k * (k - 1) / 2;
}
ll fmax(ll x) {
return x * k - k * (k - 1) / 2;
}
using namespace QUERY;
#define list shsflkhsdsdhsd
vector<ll> list;
vector<int> sol;
void mksolve(int lp, ll sum = 0) {
if(sum > 2 * a) return;
if(sol.size() == k) {
if(sum >= a) {
answer(sol);
}
return;
}
lp++;
for(int i = lp; i + k - sol.size() <= list.size(); i++) {
sol.push_back(list[i]);
sum += v[list[i]];
mksolve(i, sum);
sol.pop_back();
sum -= v[list[i]];
}
return;
}
void solve(int _N, int _K, long long _A, int _S) {
n = _N;
k = _K;
a = _A;
s = _S;
s = min(40LL, s);
int l = 0;
for(int i = 16; i >= 0; i--) {
if(l + (1 << i) >= n) continue;
if(fmin(query(l + (1 << i))) < a)
l += (1 << i);
s--;
}
//cerr << l << ' ' << s << '\n';
if(l == n)
impossible();
l++;
s = min(s, 25LL);
if(query(l) - query(l - 1) >= a) {
list.push_back(l);
for(int i = 1; i <= n && s > 0; s--, i++)
query(i),
list.push_back(i);
}
else {
int lim = (s + 3) / 2;
//cerr << lim << ' ' << s << '\n';
for(int i = l; i > 0 && lim > 0; s--, i--, lim--)
list.push_back(i),
query(i);
for(int i = max(1, l); s > 0 && i <= n; i++, s--)
list.push_back(i),
query(i);
}
sort(list.begin(), list.end());
list.resize(unique(list.begin(), list.end()) - list.begin());
//for(auto x : list) cerr << x << ' ';
//cerr << '\n';
sol.reserve(40);
mksolve(-1);
impossible();
}
컴파일 시 표준 에러 (stderr) 메시지
books.cpp: In function 'void mksolve(int, ll)':
books.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
36 | if(sol.size() == k) {
| ~~~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |