【topcoder SRM 702 DIV 2 250】TestTaking
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的更多相关文章
- Topcoder SRM 656 (Div.1) 250 RandomPancakeStack - 概率+记忆化搜索
最近连续三次TC爆零了,,,我的心好痛. 不知怎么想的,这题把题意理解成,第一次选择j,第二次选择i后,只能从1~i-1.i+1~j找,其实还可以从j+1~n中找,只要没有被选中过就行... [题意] ...
- 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) [思路] 手速太慢啦,等敲完代码的时 ...
- 【TC SRM 718 DIV 2 B】Reconstruct Graph
[Link]: [Description] 给你两个括号序列; 让你把这两个括号序列合并起来 (得按顺序合并) 使得组成的新的序列为合法序列; 即每个括号都能匹配; 问有多少种合并的方法; [Solu ...
- 【TC SRM 718 DIV 2 A】RelativeHeights
[Link]: [Description] 给你n个数字组成原数列; 然后,让你生成n个新的数列a 其中第i个数列ai为删掉原数列中第i个数字后剩余的数字组成的数列; 然后问你这n个数列组成的排序数组 ...
- TopCoder SRM 596 DIV 1 250
body { font-family: Monospaced; font-size: 12pt } pre { font-family: Monospaced; font-size: 12pt } P ...
- TopCoder SRM 667 Div.2题解
概览: T1 枚举 T2 状压DP T3 DP TopCoder SRM 667 Div.2 T1 解题思路 由于数据范围很小,所以直接枚举所有点,判断是否可行.时间复杂度O(δX × δY),空间复 ...
- TopCoder SRM 560 Div 1 - Problem 1000 BoundedOptimization & Codeforces 839 E
传送门:https://284914869.github.io/AEoj/560.html 题目简述: 定义"项"为两个不同变量相乘. 求一个由多个不同"项"相 ...
- 竞赛图的得分序列 (SRM 717 div 1 250)
SRM 717 DIV 1 中 出了这样一道题: 竞赛图就是把一个无向完全图的边定向后得到的有向图,得分序列就是每个点的出度构成的序列. 给出一个合法的竞赛图出度序列, 要求构造出原图(原题是求(u, ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
随机推荐
- 怎样利用ash监控会话
ash是很有效的监控工具之中的一个.1秒抓一次 select max(sample_time)over(),min(sample_time)over() from dba_hist_active_se ...
- Nginx系列(一)--nginx是什么?
一.介绍 Nginx是一个高性能的HTTP和反向代理server,也是一个IMAP/POP3/SMTP代理server. Nginx是一款轻量级的Webserver/反向代理server以及电子邮件代 ...
- DIV+CSS两种盒子模型(W3C盒子与IE盒子)
在辨析两种盒子模型之前.先简单说明一下什么叫盒子模型. 原理: 先说说我们在网页设计中常听的属性名:内容(content).填充(padding).边框(border).边界(margin), CSS ...
- Git安装及密钥的生成并上传本地文件到GitHub上
之前用的GitHub,不太熟练,一直在上传的过程中遇到了一些问题,看了网上诸多教程,总觉得很乱,特参考一些资料,总结了一篇完整的操作步骤,从下载安装到上传文件,亲测有效 1.下载Git软件:https ...
- [React] Render Text Only Components in React 16
In this session we create a comment component to explore how to create components that only render t ...
- Eclipse导入Maven项目出现错误:Unsupported IClasspathEntry kind=4
使用Eclipse导入Maven项目失败,提示: An internal error occurred during: "Importing Maven projects". Un ...
- Android BuildConfig:Gradle自定义你的BuildConfig
在很早之前我发布了这篇博客Android BuildConfig.DEBUG的妙用, 提到了Eclipse中通过BuildConfig.DEBUG字段用来调试Log非常好用,但是殊不知在Android ...
- Android Notification.setLatestEventInfo弃用和Notification.Builder用法
今天在学习小米便签的源码的时候,至于源码的地址,http://m.blog.csdn.net/article/details?id=50544248 ,里面有好多github的开源项目,打开项目,报错 ...
- Flask项目之手机端租房网站的实战开发(七)
说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 接着上一篇博客继续往下写 :https://blog.csdn.net/qq_41782425/article/details/8 ...
- ajax实现简单的点击左侧菜单,右侧加载不同网页
实现:ajax实现点击左侧菜单,右侧加载不同网页(在整个页面无刷新的情况下实现右侧局部刷新,用到ajax注意需要在服务器环境下运行,从HBuilder自带的服务器中打开浏览效果即可) 原理:ajax的 ...