406748: GYM102535 E Potent Plants

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Potent Plantstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Some agents attack with knives, others use only their bare fists. Several use guns of some sort, from small pistols to long range rifles. Then there are those who use very flashy explosions.

You smirk to yourself as you think of those guys. "They could hardly call themselves Agents of Covert Missions."

As for you, you pride yourself in using herbs—special plants that you grow yourself. These plants of yours produce potent leaves which could be turned into powder and pills for different uses: causing paralysis, inducing sleep, and extracting the truth from people.

Unfortunately, the Center for Interior Architecture wasn't that meticulous when designing your headquarters. You have many plants of differing weights, but the area where you are growing your plants can only handle up to a maximum weight $$$w$$$. Will you be able to grow all of your plants?

Input

The first line of input contains a single integer $$$t$$$ denoting the number of test cases.

Each test case is on one line, starting with an integer $$$w$$$ as described above, then a string $$$S$$$ representing your collection of plants.

Each plant is represented by an uppercase letter, from "A" to "Z". Plants denoted by "A" are of weight $$$1$$$, "B" of weight $$$2$$$, and so on until "Z" with weight $$$26$$$.

Constraints

  • $$$1 \leq t \leq 10^5$$$
  • $$$0 \leq w \leq 10^9$$$
  • $$$1 \leq |S| \leq 10^6$$$
  • Sum of $$$|S|$$$ in all cases will not exceed $$$10^6$$$
  • $$$S$$$ is composed of uppercase English characters
Output

For each test case, print a line stating if you could grow all the plants. Output only "YES" or "NO" (without the quotes).

ExampleInput
4
130 ACMALGOLYMPICS
2020 TWENTYTWENTY
472 THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG
473 THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG
Output
NO
YES
NO
YES

加入题单

上一题 下一题 算法标签: