当前位置:网站首页>L1-043 阅览室
L1-043 阅览室
2022-07-24 11:39:00 【Cod_ing】
注意算“平均阅读时间(以分钟为单位的精确到个位的整数时间)”时,要四舍五入,否则第5个测试用例无法通过
#include<iostream>
#include<string>
using namespace std;
typedef struct {
bool tag; //用于标记该数据项是否有效
string time;
}One;
One one[1005];
int f(int x, int y) {
//四舍五入--->y/x
y *= 10;
y /= x;
x = y % 10;
if (x >= 5) y += 10;
return y /= 10;
}
int subtra(string x, string y) {
//以分钟为单位,计算时间差---> x-y
int x1 = stoi(x.substr(0, 2));
int y1 = stoi(x.substr(3, 2));
int x2 = stoi(y.substr(0, 2));
int y2 = stoi(y.substr(3, 2));
return x1 * 60 + y1 - (x2 * 60 + y2);
}
int main() {
int N,ans1,ans2;
int num;
char ch;
string time;
cin >> N;
ans1 = ans2 = 0;
while (N) {
cin >> num >> ch >> time;
if (num == 0) {
N--;
if (ans1 == 0) {
cout << "0 0" << endl;
}
else {
ans2 = f(ans1, ans2);
cout << ans1 << " " << ans2 << endl;
}
ans1 = ans2 = 0;
}
else {
if (ch == 'S') {
one[num].tag = true;
one[num].time = time;
}
else {
if (!one[num].tag) continue;
one[num].tag = false;
ans1++;
ans2 += subtra(time, one[num].time);
}
}
}
return 0;
}
边栏推荐
- 哈希——242.有效的字母异位词
- MOS管 —— 快速复苏应用笔记(壹)[原理篇]
- [golang] golang implements the URLEncode URLDecode function
- Recommended SSH cross platform terminal tool tabby
- 2 万字详解,吃透 ES!
- Shengxin weekly issue 37
- Simply use MySQL index
- 运算放大器 —— 快速复苏笔记[壹](参数篇)
- Directional crawling Taobao product name and price (teacher Songtian)
- Depth first search and breadth first search of Graphs
猜你喜欢

JPS has no namenode and datanode reasons

Types and history of bugs in it circle

Pytorch learning -- using gradient descent method to realize univariate linear regression

1184. Distance between bus stops: simple simulation problem

tcp 服务端接收数据处理思路梳理,以及select: Invalid argument报错 笔记

JMeter runtime controller

安装jmeter

这才是开发者神器正确的打开方式!

1184. 公交站间的距离 : 简单模拟题

JMeter if controller
随机推荐
Hash - 1. Sum of two numbers - some people fall in love during the day, some people watch the sea at night, and some people can't do the first question
Linked list - Sword finger offer interview question 02.07. linked list intersection
Jackson parsing JSON detailed tutorial
[golang] before method of time type in golang
Performance test summary (I) -- basic theory
cgo+gSoap+onvif学习总结:9、go和c进行socket通信进行onvif协议处理
20000 words detailed explanation, thoroughly understand es!
【反序列化漏洞-01】序列化与反序列化简介
6k+ star,面向小白的深度学习代码库!一行代码实现所有Attention机制!
生信周刊第37期
Share the typora tool
Ask n! How many zeros are there behind
JPS has no namenode and datanode reasons
字符串——344.反转字符串
JMeter runtime controller
运算放大器 —— 快速复苏笔记[贰](应用篇)
[markdown grammar advanced] make your blog more exciting (IV: set font style and color comparison table)
Online customer service chat system source code_ Beautiful and powerful golang kernel development_ Binary operation fool installation_ Construction tutorial attached
Detailed explanation of stat function
JVM visualvm: multi hop fault handling tool