当前位置:网站首页>Acwing 692. g bus count difference + prefix and
Acwing 692. g bus count difference + prefix and
2022-07-27 19:59:00 【Alkali!】
Title Description
https://www.acwing.com/problem/content/description/694/
classical Differential prefixes and subject
Constantly add the same fixed value to all numbers in a range , Finally, find the value of a specific place .
Difference The prefix and seckill
Ideas
See my previous algorithm ideas :https://blog.csdn.net/weixin_45798993/article/details/122495960
Code
#include<iostream>
#include<cstring>
using namespace std;
const int N=5010;
int city[N];
int t,n,a,b,p,c;
int cnt=1;
int main()
{
scanf("%d",&t);
while(t--)
{
memset(city,0,sizeof(city)); // Empty the contents of the array
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
city[a]++; // Differential operation
city[b+1]--;
}
for(int i=1;i<=5000;i++) city[i]+=city[i-1]; // Find the prefix and
// Note that the upper limit is not n, It is 5000, It's the upper limit of the range
scanf("%d",&p);
printf("Case #%d: ",cnt++);
for(int i=0;i<p;i++)
{
scanf("%d",&c);
printf("%d ",city[c]);
}
printf("\n");
}
return 0;
}
边栏推荐
- IDEA:解决代码没有提示问题
- [basic knowledge of deep learning - 38] the difference between L1 regularization and L2 regularization
- 2022爱分析·智慧社区厂商全景报告 厂商征集
- UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xff in position 0: invalid start byte
- Fileoutputstream (file storage) and FileInputStream (file reading)
- 22年PMP考试【全真敏捷试题】
- 统一建模语言 (UML) 规范
- Object常用方法学习【clone和equals】
- 软件配置 | tigerVNC的下载、安装及配置
- ContentProvider of four components
猜你喜欢

信道容量、信道带宽基本概念的理解

IDEA:解决代码没有提示问题

Marqueetextview (running lantern)

Togglebutton (button switch)

Hacker introductory tutorial (very detailed) from zero basic introduction to proficiency, it is enough to read this one.

VirtualBox: set shared folder

顶级“黑客”能厉害到什么地步?无信号也能上网,专家:高端操作!

Online Judge 输出超限

第2章 入门

Broadcastreceiver (broadcast)
随机推荐
四大组件之ContentProvider
11.2DHCP
Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night
What's new in helix QAC 2022.2, the ace code static testing tool (2)
[basic knowledge of deep learning - 42] detailed explanation of logistic regression
An unknown fastcgi error occurred in IIS: 0x80070005
Detailed interpretation of IEC104 protocol (II) interaction process and protocol analysis
VALN 11.9
VS2017#include 'xxx.h'
Chapter 2 Introduction
Oracle XE版安装与用户操作
Flink introduction and operation architecture
ACL11.12
【IoT】卫朋:6000+ 字解读 | 2022年产品人必备的7个产品管理工具(1.0版)
Broadcastreceiver (broadcast)
全局函数
ACL11.12
[论文阅读] Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation
统一建模语言 (UML) 规范
Built in module 10.18