PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000076. Bài lớn bài nhỏ (Gold) (High Card Low Card (Gold))
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bài lớn bài nhỏ (Gold) (High Card Low Card (Gold))
High Card Low Card (Gold)
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
A deck has distinct cards. Elsie’s cards and play order are fixed. Bessie holds the complement and chooses her order. A higher card wins in the first rounds; a lower card wins in the last . Maximize Bessie’s wins (USACO Gold, fixed switch).
Input
Line 1: even . Next lines: Elsie’s cards in play order.
Output
Print the maximum number of rounds Bessie can win.
Subtasks
- Subtask 1 (20 points): Exactly one dataset; ; even; ; Elsie’s cards are pairwise distinct.
- Subtask 2 (30 points): Exactly one dataset; ; even; ; Elsie’s cards are pairwise distinct.
- Subtask 3 (50 points): Exactly one dataset; ; even; ; Elsie’s cards are pairwise distinct.
Example
Input
4
1
8
4
3
Output
2
Explanation
Bessie has the complementary cards 2,5,6,7 and can score at most two wins.