Submission #657604

#TimeUsernameProblemLanguageResultExecution timeMemory
657604TimDeeA Difficult(y) Choice (BOI21_books)C++17
0 / 100
8 ms208 KiB
#include"books.h" #include <bits/stdc++.h> using namespace std; using ll = long long; void solve(int n, int k, ll A, int s) { if (s!=n) return; vector<ll> a(n); for (int i=0; i<n; ++i) a[i]=skim(i+1); if (k==3) { for (int i=0; i<n-2; ++i) { for (int j=i+1; j<n-1; ++j) { int l=j+1, r=n-1; ll sum1 = a[i]+a[j]; while (l<r) { int mid=(l+r)>>1; if (sum1+a[mid]<A) l=mid+1; else r=mid; } ll sum=sum+a[r]; if ((sum>=A) && (sum<=2*A)) { answer({i+1,j+1,r+1}); return; } } } //impossible(); } }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:20:19: warning: 'sum' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |     ll sum=sum+a[r];
      |                   ^
#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...