NC25043 Protecting the Flower

Protecting the Flowers

https://ac.nowcoder.com/acm/problem/25043

NC25043 Protecting the Flower

题目地址:

https://ac.nowcoder.com/acm/problem/25043

基本思路:

又是这种改排序贪心,我们先只考虑两只牛谁先更优,假如先那么损耗的花为,假如先那么损耗的花为,那么我们可以知道只要根据的大小排序,就能决定这两只牛谁先谁后,那么实际上容易证这个对于更多牛的情况也是普遍成立的,因此根据此规则排序然后直接模拟一遍题意统计答案就行了。

参考代码:

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF (int)1e18

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

struct Node{
    int t,d;
    bool operator < (const Node &no) const {
      return t * no.d < d * no.t;//排序规则;
    }
};
vector<Node> vec;
int n,t,d;
signed main() {
  IO;
  cin >> n;
  rep(i,1,n){
    cin >> t >> d;
    vec.push_back({t,d});
  }
  sort(vec.begin(),vec.end());
  int sum = 0,ans = 0;
  for(auto it : vec){//直接模拟统计答案;
    ans += sum * it.d;
    sum += 2 * it.t;
  }
  cout << ans << '\n';
  return 0;
}
全部评论

相关推荐

机智的豹子有点心碎:UU我还在找工作还没找到,一直在搜简历怎么改,总结了这些: 1.SEO:简历根据每一个岗位定制化:使用这个岗位中所描述的工作的词,它要求什么技能就把自己的技能描述成什么样子,把SEO用在自己身上(把我的简历和个人特质,当成一个热门产品来做 “搜索引擎优化”),让HR能用最低的门槛看到我 2."顺序:把岗位要求的技能跟经历放在简历的最开头、最显眼的位置" 3.包装:简历是一个最终交付说明书,只要最终学习成长做得到就可以,在合适的范围内自我吹捧(我这个人怎么能够在HR的角度被迅速的看懂和看到,减轻HR的工作压力) 4.每点加小标题​:用6~10字概括该段内容,便于面试官快速抓取信息。 5.避免空泛描述​:拒绝“培养了组织能力”等泛泛而谈,替换为具体行动和成果。 6."使用“三段式结构”​​:每段经历按“为什么做-做了什么-结果如何”展开: ​a) 为什么做​:痛点或目标(例如“品牌声量不足”) ​b) 做​了什么:方法论(例如“趋势洞察+竞品对标+人群细分”) ​c) 结果如何​:量化成果或影响(例如“推动客户投放20万预算”)" 7.量化成果​:用数字体现工作成效(如“整理500+份资料”“撰写2万字报告”)。 这些有的是我想去的岗的,如果对你有用的话按需修改就好~加油,早日上岸!
点赞 评论 收藏
分享
林后润:听说他们有kpi,要到了简历编号就不理人了
27届求职交流
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务