zoukankan      html  css  js  c++  java
  • CTU Open Contest 2017

    B - Pond Cascade

    优先队列维护这个水池需要多少时间 或者 直接扫一遍。

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    typedef long long LL;
    const int maxn = 100000 + 10;
    const int INF = 2e9;
    
    LL a[maxn], sum[maxn];
    
    int main()
    {
        int n;
        LL flow;
        while(~scanf("%d%lld", &n, &flow))
        {
            for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    
            double t1 = INF, sum1 = 0, t2 = -INF, sum2 = 0;
            for (int i = n; i >= 1; i--)
                sum1 += a[i], t1 = min(t1, sum1*1.0/(n-i+1)/flow);
            for (int i = 1; i <= n; i++)
                sum2 += a[i], t2 = max(t2, sum2*1.0/i/flow);
    
            printf("%.8lf %.8lf
    ", t1, t2);
        }
    }
    

    D - Equinox Roller Coaster

    N个点,找出一个可以构成的最大的正方形,并且正方形的边都与坐标轴平行。

    对于每个X/Y坐标建一个表。对于每个点,枚举它X/Y坐标对应的表中所有的点(选size较小的那一维),然后判断剩下的另外两个点是否存在。

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <map>
    #include <set>
    #include <vector>
    using namespace std;
    const int maxn = 100000 + 100;
    map<int, set<int> > px, py;
    int x[maxn], y[maxn];
    
    int main()
    {
        int n;
        while(~scanf("%d", &n))
        {
            px.clear(), py.clear();
            for (int i = 1; i <= n; i++)
            {
                scanf("%d%d", &x[i], &y[i]);
                px[x[i]].insert(y[i]), py[y[i]].insert(x[i]);
            }
    
            int ans = 0;
            for (int i = 1; i <= n; i++)
            {
                if (px[x[i]].size() < py[y[i]].size())
                    for (auto j = px[x[i]].begin(); j != px[x[i]].end(); j++)
                    {
                        if ((*j) == y[i]) continue;
                        int dis = (*j) - y[i];
                        if (px[x[i] + dis].count(y[i]) && px[x[i] + dis].count(*j))
                            ans = max(ans, dis);
                    }
                else
                    for (auto j = py[y[i]].begin(); j != py[y[i]].end(); j++)
                    {
                        if ((*j) == x[i]) continue;
                        int dis = (*j) - x[i];
                        if (py[y[i] + dis].count(x[i]) && py[y[i] + dis].count(*j))
                            ans = max(ans, dis);
                    }
            }
            printf("%d
    ", ans);
        }
    }
    
  • 相关阅读:
    vs2013如何在C++中调用Lua(二)
    用vs2013编译lua源码方法(一)
    使用Sublime Text 直接运行Quick-cocos2d-x 项目
    SubmitText 中配置lua 运行环境
    在VS2012/2013上编辑和调试Quick-cocos2d-x的Lua代码
    Cocos2d-x 开发 v3.2 建立新项目并添加库文件
    计算一段函数的执行效率
    C++中嵌入Lua脚本环境搭建
    Android开发环境配置
    cocos2d-x-3.1.1 创建项目
  • 原文地址:https://www.cnblogs.com/ruthank/p/9838066.html
Copyright © 2011-2022 走看看