Submission #735684

#TimeUsernameProblemLanguageResultExecution timeMemory
735684Charizard2021A Difficult(y) Choice (BOI21_books)C++17
45 / 100
1 ms256 KiB
#include "books.h" #include<bits/stdc++.h> using namespace std; vector<long long> seq; bool IsInRange(long long A, long long Sum){ return Sum >= A && Sum <= (long long)2 * A; } void solve(int N, int K, long long A, int S){ long long low = (long long)0; long long high = (long long)N; high++; while(low + 1 < high){ long long mid = (low + high)/(long long)2; if(skim(mid) > A){ high = mid; } else{ low = mid; } } long long GreaterVal = high; if(GreaterVal < K){ impossible(); } vector<long long> minimum; long long SumMinimum = 0; for(long long i = 1; i <= K; i++){ minimum.push_back(skim(i)); SumMinimum += minimum[i - 1]; } if(GreaterVal <= N){ long long first_large_val = skim(GreaterVal); if(IsInRange(A, SumMinimum + first_large_val)){ vector<int> ans(K, GreaterVal); for(int i = 0; i < ans.size() - 1; i++){ ans[i] = i + 1; } answer(ans); } } if(GreaterVal <= K){ impossible(); } if(SumMinimum > (long long)2 * A){ impossible(); } vector<long long> Inbetween; long long SumInBetween = 0; for(long long i = GreaterVal - K; i < GreaterVal; ++i){ Inbetween.push_back(skim(i)); SumInBetween += Inbetween[i - GreaterVal + K]; } if(SumInBetween < A){ impossible(); } vector<int> ans(K); for(long long i = 0; i < ans.size(); i++){ ans[i] = i + 1; } for(long long i = K - 1; ; i--){ if(IsInRange(A, SumMinimum)){ answer(ans); } SumMinimum -= minimum[i]; SumMinimum += Inbetween[i]; ans[i] = GreaterVal - K + i; } }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:35:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for(int i = 0; i < ans.size() - 1; i++){
      |                            ~~^~~~~~~~~~~~~~~~
books.cpp:57:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(long long i = 0; i < ans.size(); i++){
      |                          ~~^~~~~~~~~~~~
#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...