Problem Statement

Recently, Alice had to take a test. The test consisted of a sequence of true/false questions. Alice was completely unprepared for the test, so she just guessed each answer.

You are given the following inputs:

an int questions: the number of questions on the test.

an int guessed: the number of questions for which Alice guessed that the answer is “true”.

an int actual: the actual number of questions for which the answer is “true”.

In the test, each correct answer was worth 1 point and each incorrect answer was worth 0 points. Compute the largest possible number of points Alice could have received.

Definition

Class:

TestTaking

Method:

findMax

Parameters:

int, int, int

Returns:

int

Method signature:

int findMax(int questions, int guessed, int actual)

(be sure your method is public)

Limits

Time limit (s):

2.000

Memory limit (MB):

256

Stack limit (MB):

256

Constraints

questions will be between 1 and 50, inclusive.

guessed, actual will be between 0 and questions, inclusive.

Examples

0)

3

1

2

Returns: 2

The test consisted of 3 statements.

Alice guessed that 1 of them is true.

Actually, there were 2 true statements on the test.

There are multiple possible outcomes of the test.

For example, it is possible that Alice wrote down the sequence of answers (false,true,false), but the correct sequence of answers is (true,false,true). In this case Alice would have received 0 points.

One possible best scenario for Alice looks as follows: Alice guessed that the answers are (false,false,true), and the correct answers are (true,false,true). In this scenario Alice would have received 0+1+1 = 2 points.

1)

3

2

1

Returns: 2

2)

5

5

0

Returns: 0

Alice guessed five times “true”, but all five correct answers were “false”. Thus, Alice certainly received 0 points.

3)

10

8

8

Returns: 10

4)

7

0

2

Returns: 5

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

【题目链接】:

【题解】



让你猜这个人最多能得多少分.

其实答案就是min(questions-guess,question-actual)+min(guess,actual);

就是尽量让这个人的答案和结果一样。



【完整代码】

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <stack>
#include <string>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second typedef pair<int,int> pii;
typedef pair<LL,LL> pll; //const int MAXN = x;
const int dx[5] = {0,1,-1,0,0};
const int dy[5] = {0,0,0,-1,1};
const double pi = acos(-1.0); class TestTaking
{
public:
int findMax(int questions, int guessed, int actual)
{
int a1 = min(guessed,actual);
int a2 = min(questions-guessed,questions-actual);
return a1+a2;
}
}; //提交时以下部分删去. int main()
{
//freopen("F:\\rush.txt","r",stdin);
TestTaking A;
int a,b,c;
cin >> a>>b>>c;
cout <<A. findMax(a,b,c);
return 0;
}

【topcoder SRM 702 DIV 2 250】TestTaking的更多相关文章

  1. Topcoder SRM 656 (Div.1) 250 RandomPancakeStack - 概率+记忆化搜索

    最近连续三次TC爆零了,,,我的心好痛. 不知怎么想的,这题把题意理解成,第一次选择j,第二次选择i后,只能从1~i-1.i+1~j找,其实还可以从j+1~n中找,只要没有被选中过就行... [题意] ...

  2. Topcoder SRM 661 (Div.1) 250 MissingLCM - 数论

    [题意] 给你一个数N(1<=N<=10^6),要求最小的M(M>N),使得lcm(n+1,n+2,...m)=lcm(1,2,3,...,m) [思路] 手速太慢啦,等敲完代码的时 ...

  3. 【TC SRM 718 DIV 2 B】Reconstruct Graph

    [Link]: [Description] 给你两个括号序列; 让你把这两个括号序列合并起来 (得按顺序合并) 使得组成的新的序列为合法序列; 即每个括号都能匹配; 问有多少种合并的方法; [Solu ...

  4. 【TC SRM 718 DIV 2 A】RelativeHeights

    [Link]: [Description] 给你n个数字组成原数列; 然后,让你生成n个新的数列a 其中第i个数列ai为删掉原数列中第i个数字后剩余的数字组成的数列; 然后问你这n个数列组成的排序数组 ...

  5. TopCoder SRM 596 DIV 1 250

    body { font-family: Monospaced; font-size: 12pt } pre { font-family: Monospaced; font-size: 12pt } P ...

  6. TopCoder SRM 667 Div.2题解

    概览: T1 枚举 T2 状压DP T3 DP TopCoder SRM 667 Div.2 T1 解题思路 由于数据范围很小,所以直接枚举所有点,判断是否可行.时间复杂度O(δX × δY),空间复 ...

  7. TopCoder SRM 560 Div 1 - Problem 1000 BoundedOptimization & Codeforces 839 E

    传送门:https://284914869.github.io/AEoj/560.html 题目简述: 定义"项"为两个不同变量相乘. 求一个由多个不同"项"相 ...

  8. 竞赛图的得分序列 (SRM 717 div 1 250)

    SRM 717 DIV 1 中 出了这样一道题: 竞赛图就是把一个无向完全图的边定向后得到的有向图,得分序列就是每个点的出度构成的序列. 给出一个合法的竞赛图出度序列, 要求构造出原图(原题是求(u, ...

  9. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

随机推荐

  1. [Docker 官方文档] 理解 Docker

    http://segmentfault.com/a/1190000002609286 什么是 Docker? Docker 是一个用于开发.交付和执行应用的开放平台,Docker 设计用来更快的交付你 ...

  2. android sdk 镜象网站

    因为一些原因.Google相关非常多服务都无法訪问,所以在非常多时候我们SDK也无法升级,当然通过技术手段肯定能够解决,可是比較麻烦,并且下载速度也不怎么样. 这里笔者介绍一个国内的Android镜像 ...

  3. PHP JSON的BUG

    将下面的数组进行 JSON 编码时出错,编码中丢掉了最后一维数组中的下标. Array ( [1] => Array ( [0] => Array ( [0] => Array ( ...

  4. 请求不携带cookie问题

    因为后端需要用到cookie做一些判断,所以在post请求前先写入了cookie.在页面未登录时,调接口能带上cookie,登录后的请求没有携带cookie,但是能看到cookie已经保存了. (ax ...

  5. BZOJ2555: SubString(后缀自动机,LCT维护Parent树)

    Description 懒得写背景了,给你一个字符串init,要求你支持两个操作 (1):在当前字符串的后面插入一个字符串 (2):询问字符串s在当前字符串中出现了几次?(作为连续子串) 你必须在线支 ...

  6. vue2.0实现银行卡类型种类的选择

    功能效果:vue2.0实现银行卡类型种类的选择 图片.png 参考代码如下: <template> <div class="app"> <header ...

  7. C#创建子线程,子线程使用委托更新控件

    一.背景 由于在窗体程序中通过点击一个button按键后需要更新TreeView控件的内容,由于等待时间比较长,主程序无法一起在那边等待,需要去处理其它的事情,所以就需要创建新的子线程来处理.因为主线 ...

  8. 失去偏执的苹果会如何?Android 会一统天下吗?

    第 一次听到Apple你绝对不会想到和手机相关.但就是这样一个不相关的东西,彻彻底底的改变了我们这个世界.说起苹果那就得必须说到乔帮主,由于苹果仅仅属于Steve jobs. 乔布斯天生聪颖.初二測得 ...

  9. theme-windowAnimationStyle 动画设置

    对于windowAnimationStyle 的引用,目前自己发现的有两处 1.就是直接在Theme 中引用的,如下 <style name="Theme.Funui" pa ...

  10. 一些常用JS函数和技巧总结

    1.JS原生函数parseInt(),返回字符串的第一个数字,默认是十进制. 2.!!data.success  //强制转换成布尔类型