답안 #1036286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036286 2024-07-27T08:13:00 Z trucmai A Difficult(y) Choice (BOI21_books) C++17
0 / 100
1 ms 344 KB
#include "books.h"
#include <bits/stdc++.h>
#ifdef LOCAL
#include "/home/trcmai/code/tools.h"
#define debug(x...)                                                           \
    cerr << "\e[91m" << __func__ << ":" << __LINE__ << " [" << #x << "] = ["; \
    _print(x);                                                                \
    cerr << "\e[39m" << endl;
#else
#define debug(x...)
#endif
using namespace std;
#define all(a) a.begin(), a.end()
#define ll long long
#define ull unsigned long long
#define endl '\n'
const int N = 1e6 + 6, LOG = 27, MOD = 1e9 + 7;
const ll INF = 1e18;

map<int, ull> a;
ull ask(int i)
{
    return (a.count(i) ? a[i] : a[i] = skim(i));
}
void solve(int N, int K, long long A, int S)
{
    int l = 1, r = N - K + 1;
    // Check xem ton tai doan lien tiep nao thoa man khong
    while (l <= r) {
        int m = (r + l) >> 1;
        ull sum = 0;
        for (int i = m; i <= m - K + 1; ++i) {
            if (sum > 2 * A)
                break;
            sum += ask(i);
        }
        if (sum >= A && sum <= 2 * A) {
            vector<int> res;
            for (int i = m; i <= m - K + 1; ++i)
                res.emplace_back(i);
            answer(res);
        }
        if (sum < A)
            l = m + 1;
        if (sum > 2 * A)
            r = m - 1;
    }
    // Neu khong ton tai, check xem doan [1,k - 1] co ghep duoc voi vi tri ith thoa man khong
    l = K, r = N;
    int pos = -1;
    while (l <= r) {
        int m = (r + l) >> 1;
        if (ask(m) >= A) {
            pos = m;
            r = m - 1;
        } else
            l = m + 1;
    }
    if (pos != -1) {
        ull sum = ask(pos);
        for (int i = 1; i <= K - 1; ++i)
            sum += ask(i);
        if (sum >= A && sum <= 2 * A) {
            vector<int> res;
            for (int i = 1; i <= K - 1; ++i)
                res.emplace_back(i);
            res.emplace_back(pos);
            answer(res);
        }
    }
    impossible();
}

Compilation message

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:33:21: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   33 |             if (sum > 2 * A)
      |                 ~~~~^~~~~~~
books.cpp:37:17: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   37 |         if (sum >= A && sum <= 2 * A) {
      |             ~~~~^~~~
books.cpp:37:29: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   37 |         if (sum >= A && sum <= 2 * A) {
      |                         ~~~~^~~~~~~~
books.cpp:43:17: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   43 |         if (sum < A)
      |             ~~~~^~~
books.cpp:45:17: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   45 |         if (sum > 2 * A)
      |             ~~~~^~~~~~~
books.cpp:53:20: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   53 |         if (ask(m) >= A) {
      |             ~~~~~~~^~~~
books.cpp:63:17: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   63 |         if (sum >= A && sum <= 2 * A) {
      |             ~~~~^~~~
books.cpp:63:29: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   63 |         if (sum >= A && sum <= 2 * A) {
      |                         ~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 1 ms 344 KB Incorrect
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 1 ms 344 KB Incorrect
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 1 ms 344 KB Incorrect
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 1 ms 344 KB Incorrect
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 1 ms 344 KB Incorrect
9 Halted 0 ms 0 KB -