Books
Problem LinkSolution by TioPatinhas — 100 pts
Code / Notes
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, t;
cin >> n >> t;
vector<int>B (n);
for (auto &x : B) cin >> x;
int esq = 0;
long long sum = 0;
int max_books = 0;
set<int>Readed;
for (int dir = 0; dir < n; dir++) {
sum += B[dir];
while (sum > t && esq <= dir) {
sum -= B[esq];
esq++;
}
max_books = max(max_books, dir - esq + 1);
}
cout << max_books << endl;
}
Last updated 1 month, 2 weeks ago