Please turn JavaScript on
Latest LCOJ Comments icon

Latest LCOJ Comments

Want to stay in touch with the latest updates from Latest LCOJ Comments? That's easy! Just subscribe clicking the Follow button below, choose topics or keywords for filtering if you want to, and we send the news to your inbox, to your phone via push notifications or we put them on your personal page here on follow.it.

Reading your RSS feed has never been easier!

Website title: Trang chủ - LCOJ: Luyencode Online Judge

Is this your feed? Claim it!

Publisher:  Unclaimed!
Message frequency:  5.55 / day

Message History

hint

Sử dụng mảng hiệu kết hợp tách hai trường hợp khi đoạn kẹo vượt quá điểm cuối vòng tròn. Nếu điểm bắt đầu nhỏ hơn hoặc bằng điểm kết thúc, đánh dấu tăng từ đầu đến cuối cộng một. Nếu ngược lại, chia thành hai đoạn đánh dấu qua lại từ đầu đến n và từ một đến cuối. Cuối cùng, chạy mảng cộng dồn từ một đến n để tính số lượng kẹo ở mỗi ô và tìm giá t...


Read full story

spoil!

ta nhận xét như sau: ~n~ <= ~3.10^4~ thì việc for 2 vòng là không thể!

ý tưởng chính

ta xét ví dụ nhỏ sau: n = 4, a[] = {1, 2, 3, 4} có các cặp: gọi ans là tổng toàn bộ. (1, 2) -> tổng 2, ans = 2 (1, 3) -> tổng 3, ans = 5 (1, 4) -> tổng 4, ans = 9 (2, 3) -> tổng 6, ans = 15 (2, 4) -> tổng 8, ans = 23 ...

Read full story

cout << ((k-1)/2)*(k/2) << "\n";


Read full story
include<bits/stdc++.h>

using namespace std; int main(){ ios::syncwithstdio(0); cin.tie(0); cout.tie(0); int T ; cin >> T; stack<int> st; while(T--){ int x ; cin >> x; if(x == 1){ int n ; cin >> n ; st.push(n); }else if(x == 2){ if(!st.empty()){ st.pop(); } }else if (x == 3){ if(st.empty()){ cout << "Empty!" <...


Read full story
include<bits/stdc++.h>

using namespace std; int main(){ ios::syncwithstdio(0); cin.tie(0); cout.tie(0); int n ; cin >> n ; vector<int> a(n); for(int i = 0 ;i<n ; i++) cin >> a[i]; int s ; cin >> s ; int l = 0 ; long long ans = 0 , sum = 0;; for(int i =0 ; i<n ; i++){ sum += a[i]; while(sum > s){ sum -= a[l]; l++...


Read full story