Submission #400531

#TimeUsernameProblemLanguageResultExecution timeMemory
400531b00n0rpA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms276 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // int a[100005]; void solve(int N, int K, long long A, int S) { for(int i = 1; i <= K; i ++) a[i] = skim(i); int sm = 0; for(int i = 1; i <= K-1; i ++) sm += a[i]; if(sm+a[K] > 2*A){ impossible(); return; } int low = K,high = N,mid,ans; while(low <= high){ mid = (low+high)/2; if(skim(mid)+sm <= 2*A){ ans = mid; low = mid+1; } else high = mid-1; } for(int i = ans; i > ans-K; i --){ sm += skim(i); if(sm >= A){ vector<int> bruh; for(int j = i; j <= ans; j++) bruh.push_back(j); for(int j = 1; j <= K-(int)bruh.size(); j ++) bruh.push_back(j); answer(bruh); } sm -= a[K-(ans-i)-2]; } }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:39:21: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |    for(int j = i; j <= ans; j++) bruh.push_back(j);
      |                   ~~^~~~~~
#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...