当前位置:网站首页>[summer daily question] Luogu p7760 [coci2016-2017 5] tuna
[summer daily question] Luogu p7760 [coci2016-2017 5] tuna
2022-07-29 07:28:00 【AC_ Dragon】
Topic link :P7760 [COCI2016-2017#5] Tuna - Luogu | New ecology of computer science education (luogu.com.cn)
Title Description
The fisherman caught N Tuna . He is going to sell these fish to a platform .
For every fish , The platform will give two estimates P1,P2. If the difference between these two values does not exceed X, Then take the larger value as the value of the fish ; Otherwise, if the difference exceeds X, Then take another value P3.
Now given N Value of fish ( There may be a 2 Or 3 individual ), Find the total value of all fish .
Input format
first line , An integer N, Indicates the number of tuna .
The second line , An integer X.
The next few lines are divided into N Three parts are used to represent the information of each fish . The format of each part is one of the following :
- There is only one line in this section , This line contains two integers P1,P2.
- There are two lines in this section , The first line contains two integers P1,P2, The second line contains an integer P3.
Output format
Output the total value of all fish .
Examples #1
The sample input #1
5
2
3 4
2 1
5 3
4 4
4 2Sample output #1
19Examples #2
The sample input #2
4
2
3 5
2 8
4
6 5
6 3
7Sample output #2
22Examples #3
The sample input #3
3
10
20 50
30
20 40
50
70 20
10Sample output #3
90Tips
【 Examples 2 explain 】
The fisherman caught it 4 Tuna , and X The value of is 2:

Therefore, the total value is 5+4+6+7 = 22.
【 Data scale and agreement 】
about 100% The data of ,1 <= N <= 20,1 <= X <= 10,1 <= P1,P2,P3 <= 100.
【 Tips and instructions 】
The title is translated from COCI 2016-2017 CONTEST #5 T1 Tuna.
The score of this question is according to COCI Original question setting , Full marks 50.
AC code:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
int x;
cin>>x;
int sum=0;
while(n--)
{
int p1,p2;
cin>>p1>>p2;
if(abs(p1-p2)>x)
{
int p3;
cin>>p3;
sum+=p3;
}
else
{
sum+=max(p1,p2);
}
}
cout<<sum;
return 0;
} 边栏推荐
- Error 1045 (28000) access denied for user 'root' @ 'localhost' solution
- 【暑期每日一题】洛谷 P4414 [COCI2006-2007#2] ABC
- Spingboot integrates the quartz framework to realize dynamic scheduled tasks (support real-time addition, deletion, modification and query tasks)
- Introduction to logback filter
- mysql 单表最多能存多少数据?
- 1-后台项目搭建
- Docker's latest super detailed tutorial - docker creates, runs, and mounts MySQL
- 【暑期每日一题】洛谷 P7760 [COCI2016-2017#5] Tuna
- 2022-07-28: what is the output of the following go language code? A:AA; B:AB; C:BA; D:BB。 package main import ( “fmt“ ) func main() { f
- 能在SQL 语句中 指定 内存参数吗?
猜你喜欢

Spingboot integrates the quartz framework to realize dynamic scheduled tasks (support real-time addition, deletion, modification and query tasks)

1 - background project construction

WPF interface layout must know basis

SEGGER 的硬件异常 分析

Variables and encryption in ansible

JS day 4 process control (if statement and switch statement)

Docker最新超详细教程——Docker创建运行MySQL并挂载

Paper reading (62):pointer networks

js中break与continue和return关键字

女研究生做“思维导图”与男友吵架!网友:吵架届的“内卷之王”....
随机推荐
PAT甲级 1154 顶点着色
我想问一下,我flink作业是以upsert-kafka的方式写入数据的,但是我在mysql里面去更
QT basic day 2 (2) QT basic components: button class, layout class, output class, input class, container and other individual examples
JS day 4 process control (if statement and switch statement)
LevelFilter简介说明
Can I specify memory parameters in SQL statements?
作业7.28 文件IO与标准IO
jdbc入门
Leetcode 209. subarray with the smallest length (2022.07.28)
I, 28, a tester, was ruthlessly dismissed in October: I want to remind people who are still learning to test
【暑期每日一题】洛谷 P6320 [COCI2006-2007#4] SIBICE
I'd like to ask, my flick job writes data in the way of upsert Kafka, but I'm more careful in MySQL
3-global exception handling
计算程序运行时间 demo
MySQL uses the client and select methods to view the summary of blob type fields
如何与斯堪尼亚SCANIA建立EDI连接?
Female graduate students do "mind mapping" and quarrel with their boyfriend! Netizen: the "king of infighting" in the quarrel
Tp6 use protobuf
Scala 高阶(九):Scala中的模式匹配
Levelfilter introduction