Codeforces Round #481 (Div. 3) G. Petya's Exams
http://codeforces.com/contest/978/problem/G
感冒是真的受不了。。。敲代码都没力气。。。
题目大意:
期末复习周,一共持续n天,有m场考试
每场考试有如下信息:
①si表示知道第i门课的考试时间是在第si天的时候
②di表示第i门课的考试时间
③ci表示准备第i门课需要ci天的复习
在考试的那一天不能复习。
问n天中每一天都需要干啥?
三种情况,休息(输出0),复习(输出复习那一门科目的id),考试(输出m+1)
思路:按照di排序(即按照截止时间),然后反过来暴力扫一遍,对于s(i)大的我们进行优先复习,所以优先队列维护一下si即可
//看看会不会爆int!数组会不会少了一维!
//取物问题一定要小心先手胜利的条件
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")
#define LL long long
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define haha printf("haha\n")
const int maxn = 1e3 + ;
vector<int> day[maxn];
int n, m;
int d[maxn], s[maxn], c[maxn];
int ans[maxn]; bool solve(){
memset(ans, -, sizeof(ans));
for (int i = ; i <= m; i++){
day[d[i]].pb(i);
ans[d[i]] = m + ;
}
priority_queue<pair<int, pair<int, int> > > que;
for (int i = n; i >= ; i--){
if (day[i].size() > ){
for (int j = ; j < day[i].size(); j++){
int p = day[i][j];
que.push(mk(s[p], mk(c[p], p)));
}
}
if (ans[i] != -) continue;
if (que.empty()){///休息
ans[i] = ;
continue;
}
int spos = que.top().fi;
int restday = que.top().se.fi;
int pos = que.top().se.se;
que.pop();
if (spos > i && restday > ) return false;
restday--;
ans[i] = pos;
if (restday == ){
continue;
}
que.push(mk(spos, mk(restday, pos)));
}
if (!que.empty()) return false;
for (int i = ; i <= n; i++){
printf("%d ", ans[i]);
}
cout << endl;
return true;
} int main(){
cin >> n >> m;
for (int i = ; i <= m; i++){
scanf("%d%d%d", s + i, d + i, c + i);
}
if (solve() == false) puts("-1");
return ;
}
Codeforces Round #481 (Div. 3) G. Petya's Exams的更多相关文章
- Codeforces Round #481 (Div. 3) G. Petya's Exams (贪心,模拟)
题意:你有\(n\)天的时间,这段时间中你有\(m\)长考试,\(s\)表示宣布考试的日期,\(d\)表示考试的时间,\(c\)表示需要准备时间,如果你不能准备好所有考试,输出\(-1\),否则输出你 ...
- Codeforces Round #582 (Div. 3)-G. Path Queries-并查集
Codeforces Round #582 (Div. 3)-G. Path Queries-并查集 [Problem Description] 给你一棵树,求有多少条简单路径\((u,v)\),满足 ...
- Codeforces Round #481 (Div. 3)
我实在是因为无聊至极来写Div3题解 感觉我主要的作用也就是翻译一下题目 第一次线上打CF的比赛,手速很重要. 这次由于所有题目都是1A,所以罚时还可以. 下面开始讲题 A.Remove Duplic ...
- Codeforces Round #547 (Div. 3) G 贪心
https://codeforces.com/contest/1141/problem/G 题意 在一棵有n个点的树上给边染色,连在同一个点上的边颜色不能相同,除非舍弃掉这个点,问最少需要多少种颜色来 ...
- Codeforces Round #541 (Div. 2) G dp + 思维 + 单调栈 or 链表 (连锁反应)
https://codeforces.com/contest/1131/problem/G 题意 给你一排m个的骨牌(m<=1e7),每块之间相距1,每块高h[i],推倒代价c[i],假如\(a ...
- Codeforces Round #346 (Div. 2) G. Fence Divercity dp
G. Fence Divercity 题目连接: http://www.codeforces.com/contest/659/problem/G Description Long ago, Vasil ...
- Codeforces Round #481 (Div. 3) 全题解
A题,题目链接:http://codeforces.com/contest/978/problem/A 解题心得:题意就是让你将这个数列去重,重复的数只保留最右边的那个,最后按顺序打印数列.set+m ...
- Codeforces Round #677 (Div. 3) G. Reducing Delivery Cost(dijkstra算法)
题目链接:https://codeforces.com/contest/1433/problem/G 题解 跑 \(n\) 遍 \(dijkstra\) 得到任意两点间的距离,然后枚举哪一条边权为 \ ...
- Codeforces Round #481 (Div. 3)Petya's Exams CodeForces - 978G
Petya studies at university. The current academic year finishes with nn special days. Petya needs to ...
随机推荐
- effective c++ 笔记 (30-31)
//---------------------------15/04/17---------------------------- //#30 透彻了解inlineing的里里外外 { /* 1: ...
- Js_增删改Cookie的值
//获得cookie 的值function cookie(name) { var cookieArray = document.cookie.split("; "); //得到分割 ...
- Selenium和TestNG
本文档由Felipe Knorr Kuhn撰写,并根据其博客上发布的一系列文章进行改编. 建模您的测试用例 在编写测试用例之前,您需要知道如何验证以及将要验证的内容.让我们使用WordPress “创 ...
- 记录Jenkins+gitlab+maven
摘要 昨天抽空将jenkins+gitlab(git)+maven整合了一下,再次记录一下以防下次再去查找省的麻烦. git.maven.java配置 启动jenkins之后进入系统管理里面的Glob ...
- 高可用Kubernetes集群-14. 部署Kubernetes集群性能监控平台
参考文档: Github介绍:https://github.com/kubernetes/heapster Github yaml文件: https://github.com/kubernetes/h ...
- 小学生都能写智能语音助手了,我这颗转战AI的心要何去何从?
前言——我是不是老了 前天看了一个关于AI类的综艺节目我感觉整个人都不好了.这个综艺的名字叫<智造将来>上面那个小屁孩自己写了一个智能语音助手,这个小屁孩叫袁翊闳是2018年百度AI开发者 ...
- Linux内核分析——第二周学习笔记
20135313吴子怡.北京电子科技学院 chapter 1 知识点梳理 (一)计算机是如何工作的?(总结)——三个法宝 ①存储程序计算机工作模型,计算机系统最最基础性的逻辑结构: ②函数调用堆栈,高 ...
- 第二个Spring冲刺周期团队进展报告
第一天:找识别不了的原因 第二天:继续找识别不了的原因 第三天:找文字库,找到tessdata语言包,放到手机SD卡根目录 第四天:了解OCR引擎 第五天:将导入tess-two导入到项目中,并进行测 ...
- 第三个Sprint ------第一天
Github账户: 账户名称:kangqu Github地址: https://github.com/kangqu/country.git Github网站全英文,表示鸭梨山大...
- 关于Win10系统下VC2013安装Unit test出现问题的解决办法
话不多说,先上图~~~ 很多同学在Vs2013安装Unit test组件时会弹出这样的对话框,极其极其让人崩溃. 当我看到这个对话框时,首先中规中矩的去官网下载.NET(但是我怎么可能没有!游戏环境包 ...