A1254 | [COCI-2012_2013-contest2]#2 INSPEKTOR
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
A new town was just inaugurated in a small country. As usual, Mirko has secured the position of the chief tax inspector. His duty is ensuring adequate accounting in all the different companies in the town.
There are N business offices along the main street, numbered 1 to N from left to right. All offices are empty in the beginning; in time, companies will move in and out of these offices. From time to time, Mirko will pass by some of the offices and inspect the accounting of only one company, the currently wealthiest one in those offices.
A company moving in is described by four integers:
T – the move-in day, numbered from town inauguration (which is day 1), K – the office number, Z – the daily profit of the company (can be negative if the company is losing money), S – balance of the company's account on move-in day.
If there is already a company in office K, that company moves out when the new company moves in.
The new company doesn't open for business (or earn profit) until the day after move-in.
Mirko's inspection stroll is described by three integers:
T – the inspection day, numbered from town inauguration, A and B – Mirko will pass by all offices with numbers between A and B, inclusive.
Since Mirko works only at the end of the day, all companies will have already finished business and posted profit for the day by the time of Mirko's stroll.
Help Mirko by writing a program to find, for each stroll, the account balance of the currently wealthiest company that Mirko is passing by.
There are N business offices along the main street, numbered 1 to N from left to right. All offices are empty in the beginning; in time, companies will move in and out of these offices. From time to time, Mirko will pass by some of the offices and inspect the accounting of only one company, the currently wealthiest one in those offices.
A company moving in is described by four integers:
T – the move-in day, numbered from town inauguration (which is day 1), K – the office number, Z – the daily profit of the company (can be negative if the company is losing money), S – balance of the company's account on move-in day.
If there is already a company in office K, that company moves out when the new company moves in.
The new company doesn't open for business (or earn profit) until the day after move-in.
Mirko's inspection stroll is described by three integers:
T – the inspection day, numbered from town inauguration, A and B – Mirko will pass by all offices with numbers between A and B, inclusive.
Since Mirko works only at the end of the day, all companies will have already finished business and posted profit for the day by the time of Mirko's stroll.
Help Mirko by writing a program to find, for each stroll, the account balance of the currently wealthiest company that Mirko is passing by.
输入格式
The first line of input contains two positive integers, N (1 ≤ N ≤ 100 000) and M (1 ≤ M ≤ 300 000),
the number of offices and events, respectively.
Each of the following M lines contains a description of one event, formatted either as “1 T K Z S” (for company move-in) or as “2 T A B” (for Mirko's inspection stroll).
All events are given chronologically, and at most one event will happen each day (that is, T will be strictly increasing). The last event's day number will be less than 106 , and all Z and S numbers' absolute values will be less than 10^
6.
the number of offices and events, respectively.
Each of the following M lines contains a description of one event, formatted either as “1 T K Z S” (for company move-in) or as “2 T A B” (for Mirko's inspection stroll).
All events are given chronologically, and at most one event will happen each day (that is, T will be strictly increasing). The last event's day number will be less than 106 , and all Z and S numbers' absolute values will be less than 10^
6.
输出格式
For each Mirko's stroll output a line containing the account balance of the company that Mirko will inspect, or the word “nema” (without quotes) if all offices that he will pass by are empty.
输入输出样例
输入 #1
2 4 1 1 1 2 4 1 2 2 3 2 2 5 1 2 2 7 1 2
输出 #1
12 17
输入 #2
3 6 1 1 1 4 -2 1 2 2 2 6 2 3 3 1 2 4 3 1 1 5 3 -6 20 2 6 2 3
输出 #2
8 10 14
输入 #3
5 9 1 1 5 4 -5 2 2 3 5 1 3 4 6 9 2 4 1 2 1 6 2 2 3 2 8 2 1 1 9 4 0 17 2 10 5 5 2 11 1 4
输出 #3
-1 nema 7 31 17
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted