不能理解需求

Cannot Comprehend Requirement

本文关键字:需求 能理解 不能      更新时间:2023-10-16

我正在努力提高我的算法技能,遇到了这个问题。下面是:http://opc.iarcs.org.in/index.php/problems/LEADGAME

我的代码是:
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char* argv[])
{
    int count;
    cin >> count;
    int winningP = 1; // winning player
    int lead = 0; // lead
    for (int i=0; i < count; i++)
    {
        int scoreA, scoreB = 0;
        cin >> scoreA >> scoreB;
        int l;
        if (scoreA > scoreB)
            l = scoreA - scoreB;
        else
            l = scoreB - scoreA;
        if (l > lead) // greater lead than what's been processed
        {
            lead = l;
            winningP = scoreA > scoreB ? 1 : 2;
        }
    }
    cout << winningP << " " << lead;
    return 0;
}

然而,在网站上,当我提交代码进行评估时,它打印出我的程序给出了错误的答案。我哪里做错了?示例输入和输出已经过验证。

你正在解决一个不同的问题。你将找到以最大优势赢得任何回合的玩家。在这个问题中,每轮的得分都是累积的,因此,如果像上面的例子一样,玩家1以58分的优势赢得第一轮,以45分的优势输掉第二轮,那么在两轮之后,玩家1仍然领先13分。