Submission #987240

#TimeUsernameProblemLanguageResultExecution timeMemory
987240VMaksimoski008A Difficult(y) Choice (BOI21_books)C++17
20 / 100
137 ms1344 KiB
#include <bits/stdc++.h>
#include "books.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

void solve(int N, int K, ll A, int S) {
    if(N == S) {
        vector<ull> v = { 0 };
        for(int i=1; i<=N; i++) v.push_back(skim(i));

        ull sum1 = 0;
        for(int i=1; i<=K; i++) sum1 += v[i];

        if(sum1 >= A && sum1 <= 2 * A) {
            vector<int> ans;
            for(int i=1; i<=K; i++) ans.push_back(i);
            answer(ans);
        }

        for(int i=2; i+K-1<=N; i++) {
            sum1 -= v[i-1];
            sum1 += v[i+K-1];
            if(sum1 > 2 * A) break;

            if(sum1 >= A && sum1 <= 2 * A) {
                vector<int> ans;
                for(int j=i; j<=i+K-1; j++) ans.push_back(j);
                answer(ans);
            }
        }

        for(int i=K; i<=N; i++) {
            if(v[i] >= A) {
                ll sum = 0;
                for(int j=1; j<=K-1; j++) sum += v[j];
                if(sum + v[i] >= A && sum + v[i] <= 2 * A) {
                    vector<int> ans;
                    for(int j=1; j<=K-1; j++) ans.push_back(j);
                    ans.push_back(i);
                    answer(ans);
                }
                break;
            }
        }

        impossible();
        return ;
    }
}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:16:17: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   16 |         if(sum1 >= A && sum1 <= 2 * A) {
      |            ~~~~~^~~~
books.cpp:16:30: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   16 |         if(sum1 >= A && sum1 <= 2 * A) {
      |                         ~~~~~^~~~~~~~
books.cpp:25:21: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   25 |             if(sum1 > 2 * A) break;
      |                ~~~~~^~~~~~~
books.cpp:27:21: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   27 |             if(sum1 >= A && sum1 <= 2 * A) {
      |                ~~~~~^~~~
books.cpp:27:34: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   27 |             if(sum1 >= A && sum1 <= 2 * A) {
      |                             ~~~~~^~~~~~~~
books.cpp:35:21: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long long unsigned int>, long long unsigned int>::value_type' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   35 |             if(v[i] >= A) {
books.cpp:38:31: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'll' {aka 'long long int'} [-Wsign-compare]
   38 |                 if(sum + v[i] >= A && sum + v[i] <= 2 * A) {
      |                    ~~~~~~~~~~~^~~~
books.cpp:38:50: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'll' {aka 'long long int'} [-Wsign-compare]
   38 |                 if(sum + v[i] >= A && sum + v[i] <= 2 * A) {
      |                                       ~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...