Codeforces Round #377 (Div. 2) D. Exams】的更多相关文章

Codeforces Round #377 (Div. 2) D. Exams    题意:给你n个考试科目编号1~n以及他们所需要的复习时间ai;(复习时间不一定要连续的,可以分开,只要复习够ai天就行了)   然后再给你m天,每天有一个值di; 其中,di==0代表这一天没有考试(所以是只能拿来复习的); 若di不为0,则di的值就代表第i天可以考编号为di的科目 ;(当然这一天也可以不考而拿来复习) .  问你最少能在第几天考完所有科目,无解则输出-1. 题解:首先,先想想最暴力的方法:从…
D. Exams Problem Description: Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. About every day we know exam for which one of m subjects can be passed on that day. Perhap…
D. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. Ab…
http://codeforces.com/contest/732/problem/D 这题我发现很多人用二分答案,但是是不用的. 我们统计一个数值all表示要准备考试的所有日子和.+m(这些时间用来考试) 那么这个all值就是理想的最小值.然后去前all个数找,贪心地复习最小的科目,然后有的考试的话,就优先考试. 如果经过这all天,复习完了(这个是肯定得),但是只是因为时间分配不好,导致没得考试(数据导致没得考试) 那么就暴力枚举后面的[all + 1, n].有得考试就去考试,刚好考完就直…
A. Exams Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/A Description Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera…
http://codeforces.com/contest/479/problem/C C. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Student Valera is an undergraduate student at the University. His end of term exams are…
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main() { int k, r, i; scanf("%d %d", &k, &r); for(i = 1; i < 10000; ++i) { if((i*k)%10 == r) break; else if((i*k) % 10 == 0){ break;…
题目链接:http://codeforces.com/contest/732/problem/D 题意: 在m天中要考k个课程, 数组a中有m个元素,表示第a[i]表示第i天可以进行哪门考试,若a[i]为0,则表示当天不能参加任何科目的考试,只能预习或者休息: 数组b中有k个元素,b[i]表示科目i需要复习几天才能通过: 问最快需要几天能通过所有考试,如果不能完成所有科目考试,输出-1: 思路: 用二分方法直接找满足条件的最小的数,其中数是指当前天是第几天,条件是指当前天以前是否能考完所有科目(…
A. Buy a Shovel time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is so…
http://codeforces.com/contest/732/problem/E 题目说得很清楚,每个电脑去插一个插座,然后要刚好的,电脑的power和sockets的值相同才行. 如果不同,还有一个操作,就是在sockets中插东西,使得sockets的值变成val / 2 + (val & 1) 要求输出最多插多少个电脑和最小的代价. 开始的时候,就有一个暴力的思路了, 就是,用优先队列维护sockets,每次弹出插了最小adapters的一个sockets,然后就是电脑那里找,有得插…