The SpongeBob SquarePants Movie

The film follows the plot of the series SpongeBob SquarePants, focusing on the anthropomorphic sea sponge of the same name (Tom Kenny). SpongeBob dreams about managing the Krusty Krab restaurant, which one day has a crisis involving a customer having no cheese on his Krabby Patty. SpongeBob arrives and saves the day, and he wakes up and cheerfully prepares for the opening ceremony for the Krusty Krab 2, hoping that his boss Mr. Krabs (Clancy Brown) will promote him to manager of the new restaurant built next door to the original Krusty Krab. At the ceremony, SpongeBob is passed over; his co-worker, Squidward Tentacles (Rodger Bumpass), has been given the promotion because Mr. Krabs thinks he is "more mature" than SpongeBob.
Meanwhile, Plankton (Mr. Lawrence), Mr. Krabs' business rival, devises a plot to steal the Krabby Patty secret formula and frame Mr. Krabs. He steals King Neptune's (Jeffrey Tambor) crown that night, leaving evidence that pins the crime on Mr. Krabs, and sends the crown to Shell City, a distant, mysterious land from which no fish has returned. That night, SpongeBob goes to his favorite restaurant, Goofy Goober's; he drowns his sorrows in ice cream with his best friend, Patrick Star (Bill Fagerbakke), waking up the next morning with a headache. King Neptune barges into the Krusty Krab 2 the same morning and threatens to slay Mr. Krabs. Although SpongeBob criticizes Mr. Krabs shortly after he arrives, he promises Neptune that he will retrieve the crown from Shell City. Neptune freezes Mr. Krabs, still certain that he is the culprit, and tells SpongeBob to return with the crown in six days for him to spare Mr. Krabs. SpongeBob and Patrick leave for Shell City in the Patty Wagon, a car shaped like a Krabby Patty.




SpongeBob and Patrick, pursued by Shell City's "cyclops" diver.
In Bikini Bottom, Plankton steals the Krabby Patty formula and uses it to produce and sell Krabby Patties at his restaurant, the Chum Bucket, with the claim that Krabs bequeathed him the recipe. He sends a hitman named Dennis (Alec Baldwin) to pursue SpongeBob and Patrick. Squidward discovers the truth about Plankton stealing Neptune's crown and tries to alert Neptune. However, Plankton uses mind-controlling bucket helmets disguised as souvenirs to control Bikini Bottom's residents, including Squidward, and renames the city Planktopolis.
Meanwhile, SpongeBob and Patrick encounter a dangerous trench, but Neptune's daughter Mindy (Scarlett Johansson) helps them past it by making them think she can make them into men. They are stopped by Dennis, who tries to crush them with his spiked boots, but he is in turn stepped on by a massive "cyclops" (really a diver) (Neil Ross). The "cyclops" grabs SpongeBob and Patrick, and goes to his beachside store, revealed to be Shell City. At the store, SpongeBob and Patrick find the crown, but are nearly killed in a lethal drying-out process with the heat lamp turned on. Their tears short-circuit the heat lamp, and its smoke activates the sprinkler system, reviving their bodies and the other dried sea creatures to be sold as souvenirs. As the sea creatures attack the diver, SpongeBob and Patrick take the crown and head for the beach. When they lose their way home, David Hasselhoff offers them a ride; Dennis catches up to them but is knocked by a catamaran back into the sea.
Back at the Krusty Krab 2, Neptune arrives to execute Mr. Krabs. Just in time, SpongeBob and Patrick return with the crown and confront Plankton, who then drops a mind-control bucket on Neptune, enslaving him. SpongeBob performs the song "Goofy Goober Rock" (performed by Jim Wise) and, after transforming into an electric guitar-wielding wizard for the duration of the song, he frees Bikini Bottom's residents. Plankton is arrested, and King Neptune thanks SpongeBob for his bravery and thaws Mr. Krabs, who makes SpongeBob manager of the Krusty Krab 2 in gratitude.

Question: At the end who was arrested for the crime?
Answer: Plankton