THPTTD_60 - Mua sách_

Xem dạng PDF

Gửi bài giải


Điểm: 7,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: books.inp
Output: books.out

Tác giả:
Nguồn bài:
HSG
Dạng bài
Ngôn ngữ cho phép
C, C#, C++, Go, Java, JavaScript, Kotlin, Pascal, Perl, PHP, PyPy, Python, Ruby, Rust, Scratch, Swift

Trong trường hợp đề bài hiển thị không chính xác, bạn có thể tải đề bài tại đây: Đề bài


Bình luận

Please read the guidelines before commenting.



  • 0
    nhankiettvt  đã bình luận lúc 25, Tháng 7, 2026, 6:20

    CODE FULL AC CHO AE THAM KHẢO

    #include <algorithm>
    #include <bitset>
    #include <climits>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <queue>
    #include <set>
    #include <stack>
    #include <string>
    #include <unordered_map>
    #include <utility>
    #include <vector>
    
    using namespace std;
    
    #define pii pair&lt;int, int>
    #define pll pair&lt;ll, ll>
    #define vi vector<int>
    #define vll vector<ll>
    #define fi first
    #define se second
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    #define ll long long
    #define ull unsigned long long
    
    #define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
    #define FORD(i, a, b) for (int i = (a); i >= (b); --i)
    #define REP(i, n) for (int i = 0; i < (n); ++i)
    
    void fast_io() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
    }
    void solve() {}
    
    int main() {
      fast_io();
      freopen("books.inp", "r", stdin);
      freopen("books.out", "w", stdout);
      int n, k;
      cin >> n >> k;
      vector<int> a(n);
      for (int &i : a)
        cin >> i;
      ull l = 0, tong = 0, dem = 0;
      for (int r = 0; r < n; r++) {
        tong += a[r];
        while (tong > k && l <= r) {
          tong -= a[l];
          l++;
        }
        dem += r - l + 1;
      }
      cout << dem;
      return 0;
    }
    
    

  • -3
    theguy777_jaboi  đã bình luận lúc 12, Tháng 6, 2025, 7:36

    help me


    • -4
      thien_365  đã bình luận lúc 21, Tháng 6, 2025, 13:18

      làm ra chưa, còn cần trợ giúp không


      • 1
        hosyhieu  đã bình luận lúc 19, Tháng 10, 2025, 15:19

        có ní ơi