【洛谷 P4086】【SACO17DEC】My Cow Ate My Homework

Description

  你有长度为n的成绩序列,最终成绩为去掉一个最低的成绩后剩下的平均值(多个最低只去掉一个),现在你可以删除前k个(1<=k<=n-2),按升序输出所有可以使你最终成绩最高的K的值。

Solution

  考虑线段树, 维护区间和与区间最小值,最后枚举k,计算出平均值,更新答案

Code

 

#include <bits/stdc++.h>
const int N = 1e5 + 10;
using namespace std;
int n, summ, m, cnt;
int a[N], ans[N];
struct emmm {
    int l, r;
    int sum, minn;
    #define l(x) tr[x].l
    #define r(x) tr[x].r
    #define sum(x) tr[x].sum
    #define minn(x) tr[x].minn
} tr[N << 2];
void build(int p, int l, int r) {
    l(p) = l;
    r(p) = r;
    if (l == r) {
        sum(p) = a[l];
        minn(p) = a[l];
        return ;
    }
    int mid = (l + r) >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
    sum(p) = sum(p << 1) + sum(p << 1 | 1);
    minn(p) = min(minn(p << 1), minn(p << 1 | 1));
}
void query(int p, int l, int r) {
    if (l <= l(p) && r >= r(p)) {
        summ += sum(p);
        m = min(m, minn(p));
        return ;
    }
    int mid = (l(p) + r(p)) >> 1;
    if (l <= mid) query(p << 1, l, r);
    if (r > mid) query(p << 1 | 1, l, r);
    return ;
}
int main() {
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    build(1, 1, n);
    double t = 0;
    for (int i = 1; i <= n - 2; i++) {
        summ = 0;
        m = 0x3f3f3f;
        query(1, i + 1, n);
        double s = (double)(summ - m) / (double)(n - i - 1);
        if (t == s) 
            ans[++cnt] = i;
        else if (s > t) {
            cnt = 0;
            ans[++cnt] = i;
            t = s;
        }
    }
    for (int i = 1; i <= cnt; i++) 
        cout << ans[i] << endl;
    return 0;
}

 

 

 

 

转载于:https://www.cnblogs.com/-sheldon/p/11428259.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
用中文总结以下内容: A number of experimental and numerical investigations have been conducted to study the MBPP stack and wavy flow field characteristics with various designs [10,11]. T. Chu et al. conducted the durability test of a 10-kW MBPP fuel cell stack containing 30 cells under dynamic driving cycles and analyzed the performance degradation mechanism [12]. X. Li et al. studied the deformation behavior of the wavy flow channels with thin metallic sheet of 316 stainless steel from both experimental and simulation aspects [13]. J. Owejan et al. designed a PEMFC stack with anode straight flow channels and cathode wavy flow channels and studied the in situ water distributions with neutron radiograph [14]. T. Tsukamoto et al. simulated a full-scale MBPP fuel cell stack of 300 cm2 active area at high current densities and used the 3D model to analyze the in-plane and through-plane parameter distributions [15]. G. Zhang et al. developed a two-fluid 3D model of PEMFC to study the multi-phase and convection effects of wave-like flow channels which are symmetric between anode and cathode sides [16]. S. Saco et al. studied the scaled up PEMFC numerically and compared straight parallel, serpentine zig-zag and straight zig-zag flow channels cell with zig-zag flow field with a transient 3D numerical model to analyze the subfreezing temperature cold start operations [18]. P. Dong et al. introduced discontinuous S-shaped and crescent ribs into flow channels based on the concept of wavy flow field for optimized design and improved energy performance [19]. I. Anyanwu et al. investigated the two-phase flow in sinusoidal channel of different geometric configurations for PEMFC and analyzed the effects of key dimensions on the droplet removal in the flow channel [20]. Y. Peng et al. simulated 5-cell stacks with commercialized flow field designs, including Ballard-like straight flow field, Honda-like wavy flow field and Toyota-like 3D mesh flow field, to investigate their thermal management performance [21]. To note, the terms such as sinusoidal, zig-zag, wave-like and Sshaped flow channels in the aforementioned literatures are similar to the so called wavy flow channels in this paper with identical channel height for the entire flow field. The through-plane constructed wavy flow channels with periodically varied channel heights are beyond the scope of this paper [22,23].
02-10
通过实验和数值计算研究了MBPP及波浪流动场特性的不同设计(10,11),Chu等人进行了包含30个电池的10 kW MBPP燃料电池堆的耐久性测试,分析了性能退化机制(12),Li等人从实验和模拟两个方面研究了316不锈钢薄金属板的波浪流道变形行为(13),Owejan等人设计了具有阳极直流道和阴极波浪流道的PEMFC堆,并用中子射线图研究了原位水分布(14),Tsukamoto等人模拟了300 cm2有效面积的全尺寸MBPP燃料电池堆,利用3D模型分析了平面及穿越面参数分布(15),Zhang等人开发了一种双流体3D模型的PEMFC,用于研究阳极和阴极之间对称的波浪流道的多相和对流效应(16),Saco等人用瞬态3D数值模型研究了放大的PEMFC,并比较了直平行流道、蛇形之字形流道和直之字形流道的单元,以及之字形流场的次冰点启动操作(18),Dong等人基于波浪流场的概念,将不连续S形和新月形筋条引入流道,实现优化设计和提升能量性能(19),Anyanwu等人研究了不同几何配置的正弦槽流道中的双相流,并分析了关键尺寸对流道中液滴排除的影响(20),Peng等人模拟了5电池堆,包括Ballard-like直流场、Honda-like波浪流场和Toyota-like 3D网格流场,研究了它们的热管理性能(21)。需要指出的是,上述文献中的正弦、之字形、波浪状和S形流道与本文中所谓的波浪流道完全相同,具有整个流场的相同沟槽高度(22,23)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值