Submission #575329

#TimeUsernameProblemLanguageResultExecution timeMemory
575329birthdaycakeA Difficult(y) Choice (BOI21_books)C++17
15 / 100
3096 ms1656 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; long long b[200001]; void solve(int n, int k, long long a, int s) { if(s == n){ set<long long>v; long long a1 = 0, a2 = 0, a3 = -1; for(int i = 0; i < n; i++) { b[i] = skim(i + 1); v.insert(b[i]); } for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ long long tot = a - (b[i] + b[j]) - 1; auto x = v.upper_bound(tot); if(x != v.end() && *x == b[i]) x = v.upper_bound(*x); if(x != v.end() && *x == b[j]) x = v.upper_bound(*x); if(x != v.end()){ if(*x + b[i] + b[j] <= a * 2 && *x + b[i] + b[j] >= a ){ a1 = i; a2 = j; a3 = *x; } } } } for(int i = 0; i < n; i++){ if(a3 == b[i]){ vector<int>fin = {i + 1, a1 + 1, a2 + 1}; answer(fin); } } impossible(); }else{ int l = 1, r = n - k + 1; while(l <= r){ long long mid = (l + r) / 2, tot = 0; vector<int>fin; for(int i = mid; i <= mid + k - 1 ;i++){ if(b[i] == 0) b[i] = skim(i); tot += b[i]; fin.push_back(i); } if(tot >= a && tot <= 2 * a){ answer(fin); } if(tot > 2 * a){ r = mid - 1; }else{ l = mid + 1; } } impossible(); } }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:35:45: warning: narrowing conversion of '(a1 + 1)' from 'long long int' to 'int' [-Wnarrowing]
   35 |                 vector<int>fin = {i + 1, a1 + 1, a2 + 1};
      |                                          ~~~^~~
books.cpp:35:45: warning: narrowing conversion of '(a1 + 1)' from 'long long int' to 'int' [-Wnarrowing]
books.cpp:35:53: warning: narrowing conversion of '(a2 + 1)' from 'long long int' to 'int' [-Wnarrowing]
   35 |                 vector<int>fin = {i + 1, a1 + 1, a2 + 1};
      |                                                  ~~~^~~
books.cpp:35:53: warning: narrowing conversion of '(a2 + 1)' from 'long long int' to 'int' [-Wnarrowing]
#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...