NEW YORK — New York drivers are the worst in the nation for a second straight year and neighboring New Jersey motorists are almost as bad, according to a test by GMAC Insurance Personal Lines on rules-of-the-road knowledge.

The national average for the test was 76.2 percent, with below 70 considered failing, according to GMAC Insurance. New York drivers scored an average of 70 percent, and New Jersey motorists averaged 70.5 percent. Motorists from Kansas ranked first, with an average score of 82.3 percent.

Maine drivers scored an average of 77.6, up from 76.2 in 2009. Massachusetts scored worse than Maine, with 75.8.

Applying the test results nationally, almost 20 percent of licensed drivers, or about 38 million motorists, “may be unfit for roads” and wouldn’t pass a state-issued written exam if taken today, the study said. The national test average fell from 76.6 percent in 2009, and 78.1 percent in 2008.

“It’s discouraging to see that overall average test scores are lower,” said Wade Bontrager, a senior vice president at the company.

“American drivers need to make safety a top priority and be aware of the rules of the road.”

The test, which consists of 20 questions pulled from state Department of Motor Vehicle exams, was taken by 5,202 licensed drivers from all 50 states and the District of Columbia. Washington, D.C., motorists were third from the bottom, with an average score of 71.9 percent.

New Jersey also scored second from the bottom last year. Idaho and Wisconsin tied for first last year. Connecticut ranked No. 34 this year, with an average score of 76.3.

Nationally, 15 percent of drivers knew the correct answer to what to do at a traffic light with a steady yellow signal — stop if it is safe to do so — according to the study. About 25 percent of participants admitted to driving while talking on mobile phones, eating and adjusting the radio or selecting songs on an iPod.