PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000036. Người thương nhân xảo quyệt (The Cunning Merchant)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Người thương nhân xảo quyệt (The Cunning Merchant)
The Cunning Merchant
Source: Luogu
Version: Phuoc Hung OJ Extended
Problem Statement
A ledger contains monthly income values, which may be negative. Each observation asserts the sum from month through equals . Determine whether an income sequence can satisfy every observation.
Monthly incomes may be negative.
This Extended version omits the original count of independent ledgers.
Input
First line contains , then triples .
Output
Print true when consistent, otherwise false.
Subtasks
- Subtask 1 (20 points): $1\le n\le12; 1\le m\le30; 1\le s\le t\le n; -10^9\le v\le10^9$.
- Subtask 2 (30 points): $1\le n\le50; 1\le m\le300; 1\le s\le t\le n; -10^9\le v\le10^9$.
- Subtask 3 (50 points): $1\le n\le99; 1\le m\le999; 1\le s\le t\le n; -10^9\le v\le10^9$.
Examples
Input
3 3
1 2 5
2 3 7
1 3 9
Output
true
Explanation
The monthly incomes meet all three observations: , , and . Consequently the ledger is consistent and the output is true.