Kattis - Association for Computing Machinery
Association for Computing Machinery
ACM (Association for Computing Machinery) organizes the International Collegiate Programming Contest (ICPC) worldwide every year.
In the ICPC, a team of three students is presented with a problem set that contains NN problems1 of varying types and difficulty levels. The teams are not told which problems are easier (or harder). As there is only one single computer per team, each team has to decide which one of the N!N! possible problem solving orders that the team wants to use. This is called the “contest strategy” and teams who are expecting to do well in an ICPC should use the optimal contest strategy for their team.
However, when a contest has ‘First to Solve Problem [‘A’/‘B’/.../‘A’+(N−1)+(N−1)] award’ – like this ICPC SG Regional Contest 15 – sponsored by Kattis, then some of the teams may throw the optimal contest strategy out of the window in order to grab the (smaller) award.
Input
The input describes a hypothetical scenario of a 300300 minute contest.
The first line contains two non-negative integers 2≤N≤132≤N≤13 and 0≤p≤N−10≤p≤N−1. The integer NN describes the number of problems in the problem set of this ACM ICPC and the integer pp is a 0-based index that describes the problem id that your team wants to solve first before attempting the other N−1N−1 problems.
The next line contains NN integers in the range between 11 and 999999, inclusive. Each integer ii describes the estimated number of minutes to solve problem id ii according to your team. You have discussed with your team mates that your team will not put the same estimation for two different problems, so there is no ambiguity.
As an ACM ICPC duration is 55 hours, or 300300 minutes, any estimation of strictly larger than 300300 minutes for a certain problem jj basically says that you estimate that your team cannot solve problem jj during contest time.
In this problem, you can assume that all your team’s estimations are perfectly accurate, i.e. if your team estimates that your team needs 3030 minutes to solve problem kk, 270270 minutes to solve another problem ll, and have no idea how to solve the rest, and decides to solve problem kk first followed by ll, then after 3030 minutes have elapsed from the start of contest, your team really gets an ‘Accepted’ verdict from Kattis for problem kk, immediately switches to problem ll for the next 270270 minutes, gets another ‘Accepted’ verdict from Kattis for problem ll at exactly 300300 minutes (in this problem, submission at minute 300300 is a valid submission2). Thus you have 22 Accepted problems and the total penalty time of 30+300=33030+300=330 minutes as per the ICPC rules.
Output
Print two integers Num_ACNum_AC and Penalty_TimePenalty_Time separated by a single space in one line.
Num_ACNum_AC is the highest number of problems that your team can solve and Penalty_TimePenalty_Time is the lowest penalty minutes that your team can get in order to solve Num_ACNum_AC problems in this 300300 minutes ACM ICPC if your team insists to solve problem pp first from the start of the contest and then use the remaining time to work on the other N−1N−1 problems.
For the example scenario above, if your team decides to solve problem ll first followed by kk, then your team still solves Num_AC=2Num_AC=2 Accepted problems, but with the total penalty of 270+300=570270+300=570 minutes.
| Sample Input 1 | Sample Output 1 |
|---|---|
7 0 |
2 330 |
| Sample Input 2 | Sample Output 2 |
|---|---|
7 1 |
2 570 |
| Sample Input 3 | Sample Output 3 |
|---|---|
7 2 |
0 0 |
| Sample Input 4 | Sample Output 4 |
|---|---|
3 0 |
2 301 |
Footnotes
- The largest number of problems in an official ACM ICPC to date is probably the recent ACM ICPC World Finals in Marrakesh, Morocco where N=13N=13.
- To simplify this problem a bit, we ignore seconds although the last submission must be done at 0404 hours, 5959minutes, and 5959 seconds (or minute 299299) in order to be considered valid.
题意
解释一下样例,输入n,p,n代表总题数,p代表第一个开始做第p题(位置从0开始),后面输入的是每一道题至少需要的时间,做了第一题后,选择最少需要的时间加上累积的时间<=300的话就是可做的,因为一道题的限制时间是300,问做出来的总题数和总时间。
思路
首先判断a[p]是否<=300,然后把a[0]与a[p]替换,将数组排序,先存下做出每一题的总时间,然后遍历判断
代码
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, p;
while(cin >> n >> p) {
int a[n];
int nn = , pp = , cnt = ;
for(int i = ; i < n; i++)
cin >> a[i];
if(a[p] <= ) {
int tmp = a[];
a[]=a[p];
a[p]=tmp;
sort(a+, a + n);
for(int i=;i<n;i++){
a[i]+=a[i-];
}
for(int i = ; i < n; i++) {
if(a[i] <= ) {
pp += a[i];
cnt++;
} else if(a[i] > )
break;
}
}
cout << cnt << " " << pp << endl;
}
}
Kattis - Association for Computing Machinery的更多相关文章
- 【AI】Computing Machinery and Intelligence - 计算机器与智能
[论文标题] Computing Machinery and Intelligence (1950) [论文作者] A. M. Turing (Alan Mathison Turing) [论文链接] ...
- 图灵的文章“Computing machinery and intelligence”译文
图灵奠基AI的力作“Computing machinery and intelligence”全文译完,摘自http://blog.sciencenet.cn/blog-2322490-112266 ...
- 数据结构与算法 Big O 备忘录与现实
不论今天的计算机技术变化,新技术的出现,所有都是来自数据结构与算法基础.我们需要温故而知新. 算法.架构.策略.机器学习之间的关系.在过往和技术人员交流时,很多人对算法和架构之间的关系感 ...
- 现在开始(Do It Now)
现在开始(Do It Now) 很多年前读大学的时候,我决定制定一个计划挑战自己:只用三个学期完成其他人通常花费四年的课程,能否毕业.这篇文章(此文为翻译)详细的说明了我在成功实现该目标过程中的所有时 ...
- The BKS System for the Philco-2000 学习笔记
最近因为学业需要阅读这一篇论文......一把鼻涕一把泪地翻了一边以求更好地理解,谁让我英语渣呢....有很多地方翻译得感觉还是有问题或者不流畅,还请大家多多指教. The BKS System fo ...
- Understand User's Intent from Speech and Text
http://research.microsoft.com/en-us/projects/IntentUnderstanding/ Understanding what users like to d ...
- 关于ACM,关于CSU
原文地址:http://tieba.baidu.com/p/2432943599 前言: 即将进入研二,ACM的事情也渐渐远去,记忆终将模糊,但那段奋斗永远让人热血沸腾.开个贴讲讲ACM与中南的故事, ...
- Graph Cut and Its Application in Computer Vision
Graph Cut and Its Application in Computer Vision 原文出处: http://lincccc.blogspot.tw/2011/04/graph-cut- ...
- How do I learn machine learning?
https://www.quora.com/How-do-I-learn-machine-learning-1?redirected_qid=6578644 How Can I Learn X? ...
随机推荐
- Python3与2的故事一
print函数:(Python3中print为一个函数,必须用括号括起来:Python2中print为class) Python 2 的 print 声明已经被 print() 函数取代了,这意味着我 ...
- Flask框架函数
title: flask学习笔记 subtitle: 1. flask框架函数 date: 2018-12-14 10:17:28 --- Flask学习 学习Miguel Grinberg的2017 ...
- prevent阻止标签默认行为&stop阻止事件冒泡
<form id="vm" v-on:submit.prevent="register"> 1.prevent是preventDefault,阻止标 ...
- Day 10 函数
函数 1.什么是函数? 函数就是具备某一功能的工具,事先将工具准备好就是函数的定义,遇到应用场景拿来就用就是函数的调用 2.为何用函数? 如果不使用函数,写程序会遇到这三个问题 1.程序冗长 2.程序 ...
- 【SPOJ 104】HIGH - Highways (高斯消元)
题目描述 In some countries building highways takes a lot of time- Maybe that's because there are many po ...
- [USACO4.2] 草地排水 Drainage Ditches (最大流)
题目背景 在农夫约翰的农场上,每逢下雨,贝茜最喜欢的三叶草地就积聚了一潭水.这意味着草地被水淹没了,并且小草要继续生长还要花相当长一段时间.因此,农夫约翰修建了一套排水系统来使贝茜的草地免除被大水淹没 ...
- CSS中选择器优先级的权重计算
CSS中选择器优先级的权重计算 先看一段代码,如下: a{ color: red; } #box a{ color: green; } [class="box"] a{ color ...
- 【codeforces 803D】Magazine Ad
[题目链接]:http://codeforces.com/contest/803/problem/D [题意] 给你一个字符串; 其中的空格和连字符表示可以折叠的部分 (就是说能在那个位置把字符串分成 ...
- SSH框架整合截图总结(三)
联系人信息查询1 点击 联系人信息查询 超链接时候,到查询页面 (1)在查询页面中,选择客户,根据客户进行查询 下拉表框显示所有客户 可以根据所属的客户进行联系人查询 2 在查询页面中,输入值,提 ...
- Callable与Futrue创建线程
接口callable <V> 类型参数 V-call方法的结构类型 public interface Callable<V> 返回结果并且可能抛出的异常的任务.实现者定义一 ...