不能理解需求
Cannot Comprehend Requirement
我正在努力提高我的算法技能,遇到了这个问题。下面是: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分。
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 你能重载对象变量名本身返回的内容吗
- 有人能分解一下这个c++模板的语法吗
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 试试完美的正方形,你能给点小费吗
- 有人能帮我理解这个c++代码吗
- 如何理解"Temporary objs are destroyed as the last step in evaluating the full-expression"?谁能用一些简单的例子来说明这
- 我写了一个简单的矢量程序,在其中我得到了以下输出。你能帮我理解它的输出吗?
- 理解符号表的输入(当不存在标头功能时)
- 你能帮我理解"significant digits"在浮点数学中的含义吗?
- 不能理解这个SEGFAULT
- 我怎么能理解,如果一个指针被删除在c++
- 我不能理解const char*和char*之间的区别
- c++不能理解为什么这段代码不是线程安全的
- 不能理解需求
- 谁能帮我理解这个错误? "definition of implicitly-declared ‘classA::classA()’"
- 不能理解快速选择算法
- C++我能正确理解多态性吗
- 你能帮我理解这个C++模板代码吗