zoukankan      html  css  js  c++  java
  • poj 3253 Fence Repair 夜

    http://poj.org/problem?id=3253

    #include<iostream>
    #include<cstdio>
    #include<string.h>
    #include<algorithm>
    #include<queue>
    #include<vector>
    #include<cmath>

    using  namespace std;

    int main()
    {
        //freopen("data.txt","r",stdin);
        //freopen("A-large-practice.out","w",stdout);
        priority_queue<long long,vector<long long>,greater<long long> >str;
        long long ans;
        int n,i;
        while(scanf("%d",&n)!=EOF)
        {
            long long temp1,temp2,temp3;
            for(i=0;i<n;i++)
            {
                cin>>temp1;
                str.push(temp1);
            }
            ans=0;
            temp2=0;
            temp3=0;
            do
            {
               ans+=temp2;
               ans+=temp3;
               temp2=str.top();
               str.pop();
               if(str.empty())
               break;
               temp3=str.top();
               str.pop();
               str.push(temp2+temp3);
            }while(!str.empty());
            cout<<ans<<endl;
        }
        return 0;
    }

  • 相关阅读:
    PHP图像处理之画图
    PHP中的日期和时间
    windows socket网络编程基础知识
    socket编程(Linux)
    变量作用域
    JavaScript中的this
    基于jQuery的2048小游戏设计(网页版)
    I/O流
    并发名词解释
    synchronized 实现原理
  • 原文地址:https://www.cnblogs.com/liulangye/p/2421951.html
Copyright © 2011-2022 走看看