当前位置:网站首页>PAT甲级 1046 Shortest Distance
PAT甲级 1046 Shortest Distance
2022-07-26 15:55:00 【九是否非随机的称呼】
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int main(void){
int i, j, k, m, n, h, mm, nn;
cin>>m;
vector<int> exits, allexit, cumsum;
exits.resize(m + 1);
cumsum.resize(m + 1);
cumsum[0] = 0;
for(i=1; i<=m; i++){
cin>>n;
exits[i] = n;
cumsum[i] = n + cumsum[i - 1];
}
cin>>m;
for(i=1; i<=m; i++){
cin>>n>>h;
allexit.push_back(n);
allexit.push_back(h);
}
int minmin, maxmax, tmp, tmp0, tmp00, sizes;
sizes = exits.size();
for(i = 0; i < m; i++){
mm = allexit[2 * i];
nn = allexit[2 * i + 1];
maxmax = max(mm, nn);
minmin = min(mm, nn);
tmp = cumsum[maxmax - 1] - cumsum[minmin - 1];
tmp0 = cumsum[sizes - 2] - cumsum[maxmax - 1] + exits[sizes - 1];
tmp00 = cumsum[minmin - 1];
tmp = min(tmp, tmp0 + tmp00);
cout<<tmp<<endl;
}
return 0;
}边栏推荐
- 八叉树建立地图并实现路径规划导航
- Paper: all models are wrong, but many are useful: all models are wrong, but many are useful: understand the importance of variables by studying a whole class of prediction models at the same time
- .net get injection object manually
- “核弹级” Log4j 漏洞仍普遍存在,并造成持续影响
- 国元期货网上开户安全吗?开户办理流程是怎样的?
- Teach the big model to skip the "useless" layer and improve the reasoning speed × 3. The performance remains unchanged, and the new method of Google MIT is popular
- ES6 advanced - query commodity cases
- 共议公共数据开放,“数牍方案”亮相数字中国建设峰会
- Quanzhi a40i industrial core board, 100% domestic 4-core arm cortex-a7, supports "dual screen abnormal display" [display interface capability, preferred scheme for industrial HMI]
- 如何通过ETL调度工具 TASKCTL 使用作业插件类型调用 kettle作业?
猜你喜欢

Teach the big model to skip the "useless" layer and improve the reasoning speed × 3. The performance remains unchanged, and the new method of Google MIT is popular

大型仿人机器人整机构型研究与应用

Question collection come and ask nllb authors! (Zhiyuan live issue 24)

教大模型自己跳过“无用”层,推理速度×3性能不变,谷歌MIT这个新方法火了...

Vs2019debug mode too laggy can't enter the breakpoint

Paper:《All Models are Wrong, but Many are Useful: 所有模型都是错误的,但许多模型都是有用的:通过同时研究一整类预测模型来了解变量的重要性》翻译与解读

技术风向标 | 云原生技术架构成熟度模型解读

13年资深开发者分享一年学习Rust经历:从必备书目到代码练习一网打尽

潘多拉 IOT 开发板学习(RT-Thread)—— 实验17 ESP8266 实验(学习笔记)

2022你的安全感是什么?沃尔沃年中问道
随机推荐
Paper:《All Models are Wrong, but Many are Useful: 所有模型都是错误的,但许多模型都是有用的:通过同时研究一整类预测模型来了解变量的重要性》翻译与解读
My brother created his own AI anti procrastination system, and he was "blinded" when playing with his mobile phone | reddit was hot
我们被一个 kong 的性能 bug 折腾了一个通宵
Parker pump pv140r1k1t1pmmc
Basic specification of component development, localstorage and sessionstorage, object data to basic value, prototype chain use
Super simple! It only takes a few steps to customize the weather assistant for TA!!
“核弹级” Log4j 漏洞仍普遍存在,并造成持续影响
bucher齿轮泵QX81-400R301
博途PLC顺序开关机功能块(SCL)
中金财富炒股安全吗 手续费最便宜的证券公司
线程和进程
Some cutting-edge research work sharing of SAP ABAP NetWeaver containerization
TKE集群节点max-pod是如何配置的
泰山OFFICE技术讲座:WORD的缩放比例与显示略有差异
C# 给Word每一页设置不同文字水印
TI C6000 TMS320C6678 DSP+ Zynq-7045的ZYNQ PS + PL异构多核案例开发手册(1)
2022年全国最新消防设施操作员(高级消防设施操作员)考试试题及答案
我们被一个 kong 的性能 bug 折腾了一个通宵
Change an ergonomic chair to relieve the old waist of sitting and writing code~
We were tossed all night by a Kong performance bug
https://github.com/ZouJiu1/PAT