当前位置:网站首页>[daily question in summer] Luogu p1568 race
[daily question in summer] Luogu p1568 race
2022-07-01 04:48:00 【AC_ Dragon】
Topic link :P1568 Race - Luogu | New ecology of computer science education (luogu.com.cn)
Background
Race
Title Description
SH My running performance has not been ideal . To help SH Improve your grades ,KC Decided to have a race with him . The starting point of the competition is in front of the farmer's house , They set out at the same time , In the same direction , Until the end ---- Under a tree far from the farm .
Their running speed is constant for some time . such as :SH before 3 The speed for a period of time is 5, next 6 The speed in a period of time is 10. Their total game time is the same . They want to be able to count the number of changes in the leading order throughout the game . for instance , Some time SH leading , Next moment KC leading , This is a change in the leading order ; If at some point SH leading , For a while KC Catch up and talk to SH Do many things at once , But it finally surpassed SH, This is also a change in the leading order .
Input format
The first 1 That's ok :N and M(1 <= N, M <= 1000).
Next N That's ok : Two integers per line , describe SH A run , Respectively represent the paragraph SH The speed of running and the duration of this speed . All data ranges [1..1000].
And then the next M That's ok : Two integers per line , describe KC A run , Respectively represent the paragraph KC The speed of running and the duration of this speed . All data ranges [1..1000].
Output format
a line : The number of changes in the leading order during the whole competition .
Examples #1
The sample input #1
4 3
1 2
4 1
1 1
2 10
2 3
1 2
3 9Sample output #1
2Tips
Input :SH before 2 The speed per unit time is 1, next 1 The speed per unit time is 4, next 1 The speed per unit time is 1, Last 10 The speed per unit time is 2.KC before 3 The speed per unit time is 2, next 2 The speed per unit time is 1, Last 9 The speed per unit time is 3.
Output : After the game starts KC leading , Until the first 5 Unit time SH exceed KC( The first leading order change ), And then 7 Unit time ,KC Anti super SH, Become a leader ( The second leading order change ).
AC code:( Be sure to turn it on long long!!!)
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
typedef long long ll;
vector<ll> s1,s2;
ll n,m;
cin>>n>>m;
ll s=0;
while(n--)
{
ll a,b;
cin>>a>>b;
while(b--)
{
s+=a;
s1.push_back(s);
}
}
s=0;
while(m--)
{
ll a,b;
cin>>a>>b;
while(b--)
{
s+=a;
s2.push_back(s);
}
}
//i+1 1 2 3 4 5 6 7 8 9 10 11 12 13 14
//s1[i] 1 2 6 7 9 11 13 15 17 19 21 23 25 27
//s2[i] 2 4 6 7 8 11 14 17 20 23 26 29 32 35
//s2[i]-s1[i] 1 2 0 0 -1 0 1 2 3 4 5 6 7 8
ll cnt=0;
vector<ll> res;
for(ll i=0;i<s1.size();i++)
{
if(s1[i]!=s2[i]) // Route difference (s2[i]-s1[i])==0 Do not put
res.push_back(s2[i]-s1[i]);
}
for(ll i=1;i<res.size();i++)
if(res[i]*res[i-1]<0)
cnt++;
cout<<cnt;
return 0;
} 边栏推荐
- STM32扩展板 温度传感器和温湿度传感器的使用
- 【硬十宝典】——2.【基础知识】开关电源各种拓扑结构的特点
- CF1638E. Colorful operations Kodori tree + differential tree array
- LM small programmable controller software (based on CoDeSys) note 19: errors do not match the profile of the target
- C read / write application configuration file app exe. Config and display it on the interface
- 对象的序列化与反序列化
- 分布式全局唯一ID解决方案详解
- The index is invalid
- Pytorch(一) —— 基本语法
- 打印流与System.setout();
猜你喜欢

【暑期每日一题】洛谷 P5886 Hello, 2020!

数据加载及预处理

解决:拖动xib控件到代码文件中,报错setValue:forUndefinedKey:this class is not key value coding-compliant for the key
![解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *](/img/88/0b99d1db2cdc70ab72d2b3c623dfaa.jpg)
解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *
![AssertionError assert I.ndim == 4 and I.shape[1] == 3](/img/b1/0109bb0f893eb4c8915df36c100907.png)
AssertionError assert I.ndim == 4 and I.shape[1] == 3

技术分享| 融合调度中的广播功能设计

2022 hoisting machinery command registration examination and hoisting machinery command examination registration

RuntimeError: “max_pool2d“ not implemented for ‘Long‘

Common methods in transforms
![[hard ten treasures] - 2 [basic knowledge] characteristics of various topological structures of switching power supply](/img/c2/6dfb9f477306edb46ff2a6a6ca32dd.png)
[hard ten treasures] - 2 [basic knowledge] characteristics of various topological structures of switching power supply
随机推荐
神经网络-非线性激活
Neural network - nonlinear activation
How to do the performance pressure test of "Health Code"
[ue4] event distribution mechanism of reflective event distributor and active call event mechanism
LeetCode_58(最后一个单词的长度)
Registration of P cylinder filling examination in 2022 and analysis of P cylinder filling
[FTP] common FTP commands, updating continuously
PR 2021 quick start tutorial, learn about the and functions of the timeline panel
Neural networks - use of maximum pooling
LM小型可编程控制器软件(基于CoDeSys)笔记二十:plc通过驱动器控制步进电机
JVM栈和堆简介
线程类的几大创建方法
数据加载及预处理
STM32扩展版 按键扫描
分布式锁的实现
打印流与System.setout();
2022 t elevator repair new version test questions and t elevator repair simulation test question bank
CF1638E. Colorful operations Kodori tree + differential tree array
Take a cold bath
Pytoch (I) -- basic grammar