Skip to content

Add 1110.md#141

Merged
MasterIceZ merged 5 commits intoprogramming-in-th:masterfrom
Phluenam:add_1110
Aug 6, 2025
Merged

Add 1110.md#141
MasterIceZ merged 5 commits intoprogramming-in-th:masterfrom
Phluenam:add_1110

Conversation

@Phluenam
Copy link
Copy Markdown
Contributor

Rendering : 1110_render.pdf

@leomotors leomotors requested a review from Copilot August 6, 2025 16:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new solution document (1110.md) that explains an algorithm for finding pairs (l,r) in an array where the median equals k. The document provides solutions for two different constraints: N ≤ 1000 and N ≤ 1000000, with time complexities of O(N²) and O(N) respectively.

md/1110.md Outdated

เมื่อกำหนัด $L_s$ เป็นจำนวน $l$ ที่ทำให้ $SL[l]=s$ และ $R_s$ เป็นจำนวน $r$ ที่ทำให้ $ SR[r] =s$ จะได้ว่าคำตอบคือ $\sum_{s=-N}^N L_sR_{-s}$ (เพราะเมื่อ $SL[l] =s$ และ $ SR[r] =-s$ จะได้ว่า $\Sigma_{i=l}^{x} C[i] + \Sigma_{i=x}^r C[i]= s - s = 0$)

เราสามารถคำนวณ $L_s$ ได้โดยการไล่คำนวณ $SL[l]$ ทุกตั้งตั้งแต่ $l=x$ ลงไปถึง $l=1$ และเพิ่ม $L_s$ ทุกครั้งที่ $SL[l] = s$ โดยเริ่มจาก $SL[x] = 0$ และคำนวณ $SL[l] = SL[l+1] + C[l]$ สำหรับ $l$ ต่อๆ ไป สามารถใช้วิธีในทำนองเดียวกันในการคำนวณ $R_s$ โดยคำนวณ $SR[r]$ เริ่มจาก $r=x$ ไปจนถึง $r=N$
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a duplicate word 'ตั้ง' in 'ทุกตั้งตั้งแต่'. It should be 'ทุกตั้งแต่' (from every).

Suggested change
เราสามารถคำนวณ $L_s$ ได้โดยการไล่คำนวณ $SL[l]$ ทุกตั้งตั้งแต่ $l=x$ ลงไปถึง $l=1$ และเพิ่ม $L_s$ ทุกครั้งที่ $SL[l] = s$ โดยเริ่มจาก $SL[x] = 0$ และคำนวณ $SL[l] = SL[l+1] + C[l]$ สำหรับ $l$ ต่อๆ ไป สามารถใช้วิธีในทำนองเดียวกันในการคำนวณ $R_s$ โดยคำนวณ $SR[r]$ เริ่มจาก $r=x$ ไปจนถึง $r=N$
เราสามารถคำนวณ $L_s$ ได้โดยการไล่คำนวณ $SL[l]$ ทุกตั้งแต่ $l=x$ ลงไปถึง $l=1$ และเพิ่ม $L_s$ ทุกครั้งที่ $SL[l] = s$ โดยเริ่มจาก $SL[x] = 0$ และคำนวณ $SL[l] = SL[l+1] + C[l]$ สำหรับ $l$ ต่อๆ ไป สามารถใช้วิธีในทำนองเดียวกันในการคำนวณ $R_s$ โดยคำนวณ $SR[r]$ เริ่มจาก $r=x$ ไปจนถึง $r=N$

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@MasterIceZ MasterIceZ merged commit 64f18c5 into programming-in-th:master Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants