当前位置: 首页 > news >正文

旅游网站首页图片重装电脑后没有wordpress

旅游网站首页图片,重装电脑后没有wordpress,南京市建设局网站,兖州那有做网站的思维、贪心、综合 排队打水 这道题目不算难,但是不注意还是会出现很多错误,比如结构体的书写。以及自定义结构体排序。还有这里做的优化,使用前缀和记录打水的等待时间,但是这里很容易出错的点在于等待时间是应该是记录的前一个…

思维、贪心、综合

排队打水

这道题目不算难,但是不注意还是会出现很多错误,比如结构体的书写。以及自定义结构体排序。还有这里做的优化,使用前缀和记录打水的等待时间,但是这里很容易出错的点在于等待时间是应该是记录的前一个人的前缀和。因为它不需要等待自己打水的等待时间。

#include<bits/stdc++.h>
using namespace std;
int n;
struct node{int index;int t;
}a[1010];
int s[1010];
bool cmp(node a, node b){return  a.t < b.t;
}
int main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n;for(int i = 1; i <= n; i++){cin >> a[i].t;a[i].index = i;}sort(a + 1, a + n + 1, cmp);double ans = 0;for(int i = 1; i <= n; i++){s[i] += s[i - 1] + a[i].t; //构建前缀和数组ans += s[i - 1];cout << a[i].index << " ";}cout << endl;ans /= n;cout << fixed << setprecision(2) << ans;return 0;
}

合并果子

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
int main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n;priority_queue<ll, vector<ll>, greater<>> q;for(int i = 0; i < n; i++){int num;cin >> num;q.push(num);}ll ans = 0;while(q.size() >= 2){ll a = q.top(); q.pop();ll b = q.top(); q.pop();ans += a + b;q.push(a + b);}cout << ans;return 0;
}

平均分配

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
struct node{ll b;ll c;ll diff;
}pr[200001];
bool cmp(node f, node l){return f.diff > l.diff;
}
int main(){ios::sync_with_stdio(0);cin.tie(0);int n;cin >> n;for(int i = 1; i <= 2*n; i++){cin >> pr[i].b;}for(int i = 1; i <= 2*n; i++){cin >> pr[i].c;pr[i].diff = pr[i].b - pr[i].c; // 计算差值,降序排列,前n个数就是b>c的,后n个用n即可}sort(pr + 1, pr + 2 * n + 1, cmp);ll ans = 0;for(int i = 1; i <= n; i++){ans += pr[i].b;}for(int i = n + 1; i <= 2*n; i++){ans += pr[i].c;}cout << ans;return 0;
}

梦境巡查

#include<bits/stdc++.h>
using namespace std;
int n;
int a[100010], w[100010], b[100010];
void get_min(int lost){int begin = 0;int cur = 0;for(int i = 0; i <= n; i++){if(cur < a[i]){ // 当前值小于a[i]begin += a[i] - cur; // 初始值加上a[i] - curcur = a[i];}cur -= a[i];if(i != lost - 1) cur += b[i + 1];}w[lost] = begin;
}
int main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n;for(int i = 0; i <= n; i++){cin >> a[i];}for(int i = 1; i <= n; i++){cin >> b[i];}for(int i = 1; i <= n; i++){get_min(i);cout << w[i] << " ";}return 0;
}

双指针,高精度,离散化

消消乐

#include<bits/stdc++.h>
using namespace std;
int main(){ios::sync_with_stdio(0);cin.tie(0);string str;cin >> str;int l = 0;int r = str.size() - 1;int ans = str.size();while(l < r){if(str[l] == 'A' && str[r] == 'B'){ans -= 2;l++;r--;}else if(str[l] == 'B') l++;else if(str[r] == 'A') r--;}cout << ans;return 0;
}

A+B(高精度)

#include<bits/stdc++.h>
using namespace std;
vector<int> add(vector<int> &a, vector<int> &b){vector<int> c;int t = 0;for(int i = 0; i < a.size() || i < b.size(); i++){if(i < a.size()) t += a[i];if(i < b.size()) t += b[i];c.push_back(t%10);t /= 10;}if(t) c.push_back(1);return c;
}
int main(){ios::sync_with_stdio(0);cin.tie(0);vector<int> a, b;string sa, sb;cin >> sa >> sb;for(int i = sa.size() - 1; i >= 0; i--) a.push_back(sa[i] - '0');for(int i = sb.size() - 1; i >= 0; i--) b.push_back(sb[i] - '0');vector<int> c = add(a, b);for(int i = c.size() - 1; i >= 0; i--) cout << c[i];return 0;
}

区间和

#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
const int N = 300010;
int n, m;
int a[N], s[N];
vector<int> alls;
vector<PII> add, query;
int find(int x){int l = 0, r = alls.size() - 1;while(l < r){int mid = l + r >> 1;if(alls[mid] >= x) r = mid;else l = mid + 1;}return r + 1;
}
int main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m;for(int i = 0; i < n; i++){int x, c;cin >> x >> c;add.push_back({x, c});alls.push_back(x);}for(int i = 0; i < m; i++){int l, r;cin >> l >> r;query.push_back({l, r});alls.push_back(l);alls.push_back(r);}sort(alls.begin(), alls.end());alls.erase(unique(alls.begin(), alls.end()), alls.end());for(auto item : add){int x = find(item.first);a[x] += item.second;}for(int i = 1; i <= alls.size(); i++) s[i] = s[i - 1] + a[i];for(auto item : query){int l = find(item.first), r = find(item.second);cout << s[r] - s[l - 1] <<endl;}return 0;
}
http://www.dtcms.com/a/575448.html

相关文章:

  • 公司专业做网站唐山网站建设zzvg
  • 建设服装网站的意义微信公众平台小程序管理
  • 北京市建设厅官方网站萧山建设银行招聘网站
  • PK10如何自己做网站做一个app开发多少钱
  • 网站流量下降管理咨询公司好不好做
  • 网络培训网站开发文献综述网页升级紧急通知域名
  • 全屏网站沈阳网势科技有限公司怎么样
  • 光触媒网站建设wordpress4.7.0下载
  • 珠海网络公司网站建设潍坊网络科技有限公司
  • 做资讯的网站黄页网怎么样
  • 网站建设优化保定织梦网站代码
  • 网站空间地址wordpress爬取豆瓣电影简介
  • 贵州网站建设推荐wordpress自带重定向
  • 【计算机软件资格考试】软考综合知识题高频考题及答案解析5
  • 网站icp备案信息是什么意思2023前端开发的就业现状
  • 网站开发包括除了亚马逊还有啥网站做海淘
  • 做推广哪个网站好手机移动网站设计
  • 手机网站建设设计建设银行武威分行网站
  • 郑州专业网站制作费用报价怎样下载做网站的软件
  • 做电影网站的软件百度做网站效果怎么样
  • 深圳系统网站开发网站设计制作从哪
  • 济南建设网站的公司wordpress响应
  • 微信清粉网站开发3g 手机网站
  • 【Android】正式打包 Release 发布版本(创建秘钥,配置秘钥,打包签名)
  • 质量基础设施一站式服务工作站制作一般网站
  • 做网站的工作流程夫唯老师seo
  • 基于Springboot+Vue的小说网站平台
  • 南充移动网站建设qq群推广方法
  • 2025年11月5日 AI快讯
  • 宝安公司网站建设qq公众平台