Skip to main content
Back to problems
Codeforces
Medium
Arrays
Sorting
Math
Vasya and Wrestling

Given two wrestlers' moves across rounds, determine the winner by comparing total points and, if tied, the best prefix score.

Acceptance 0%
Problem Statement

Problem

Two wrestlers, Vasya and Petya, take part in a match consisting of several rounds. In each round, one wrestler gains some number of points, and the other wrestler may gain points as well depending on the move description.

Your task is to determine the winner using the match rules:

  1. The wrestler with the larger total score wins.
  2. If the total scores are equal, compare the sequence of running score differences after each round and choose the wrestler who was ahead earlier in the match.
  3. If both the total score and the running differences tie, prefer the wrestler whose best scoring segment is lexicographically larger by score contribution, then by who achieved it first.

This is a classic scoring-and-tie-breaking simulation problem: process the rounds in order, maintain cumulative scores, and apply the required tie-break rule carefully.

Goal

Return the winner's name according to the match rules.

Input Format

  • The input describes the sequence of rounds in a wrestling match.
  • Each round contains the points gained by the wrestlers in that round.
  • The exact number of rounds and the per-round values follow the standard contest format.

Output Format

  • Output the name of the winner.
  • If the rules require it, use the prescribed tie-breaking outcome.

Constraints

  • The number of rounds is small enough for a single linear scan.
  • Round values fit within standard 32-bit signed integer ranges.
  • A correct solution should use O(n)O(n) time and O(1)O(1) extra space.
Examples
Sample cases returned by the problem API.

Example 1

Input

3
10 5
7 8
6 2

Output

Vasya

Explanation

After summing the rounds, Vasya finishes with a larger total score, so he wins.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.