当前位置:网站首页>牛客 - 最佳直播时间 (差分)
牛客 - 最佳直播时间 (差分)
2022-08-03 07:59:00 【GHOSTANDBREAD】
题目链接:https://ac.nowcoder.com/acm/contest/38305/E
思路:
读入一段时间,这个时间段的数值都加1,最后数值最大的就是数就是答案
代码:
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
const int N = 86400 + 10;
int s[N];
int main() {
int n;
scanf("%d", &n);
while(n --) {
int a, b, c, d, e, f;
scanf("%d:%d:%d - %d:%d:%d", &a, &b, &c, &d, &e, &f);
s[(a * 60 + b) * 60 + c] ++;
s[(d * 60 + e) * 60 + f + 1] --;
}
int maxn = -1;
for(int i = 1; i <= 86410; i ++) {
s[i] += s[i - 1];
maxn = max(maxn, s[i]);
}
printf("%d", maxn);
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Roson的Qt之旅#105 QML Image引用大尺寸图片
pyspark---low frequency feature processing
How does Mysql query two data tables for the same fields in two tables at the same time
如何在安装GBase 8c数据库的时候,报错显示“Host ips belong to different cluster?
VR全景市场拓展技巧之“拓客宝典”
推荐系统-排序层-模型:Wide&Deep
36氪详情页AES
ArcEngine(八)用IWorkspaceFactory加载矢量数据
【TPC-DS】25张表的详细介绍,SQL的查询特征
AI mid-stage sequence labeling task: three data set construction process records
wordpress: 裁剪您的图片时发生错误
图解Kernel Device Tree(设备树)的使用
timestamp
循环神经网络RNN基础《PyTorch深度学习实践》
LeetCode 264:丑数
数仓4.0(一)
Mysql如何对两张表的相同字段,同时查询两张数据表
Taro框架-微信小程序-调用微信支付
ArcEngine(二)加载地图文档
千万级别的表分页查询非常慢,怎么办?