码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #247 (Div. 2) B - Shower Line

时间:2014-06-14 22:57:10      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   ext   color   

模拟即可

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    vector<int> a(5);
    for(int i = 0; i < 5; ++ i) a[i] = i;
    int g[5][5];
    for(int i = 0 ; i < 5; ++ i){
        for(int j = 0 ; j < 5; ++ j){
            cin >> g[i][j];
        }
    }
    int maxHappiness = 0;
    do{
        maxHappiness = max(g[a[1]][a[0]]+g[a[0]][a[1]]+g[a[3]][a[2]]+g[a[2]][a[3]]+g[a[2]][a[1]]+g[a[1]][a[2]]+g[a[4]][a[3]]+g[a[3]][a[4]]+g[a[3]][a[2]]+g[a[2]][a[3]]+g[a[4]][a[3]]+g[a[3]][a[4]],maxHappiness);
        cout<<a[0]<<a[1]<<a[2]<<a[3]<<a[4]<<endl;
        cout<<maxHappiness<<endl;
        
    }while(next_permutation(a.begin(),a.end()));
    cout<<maxHappiness<<endl;
    
}

 

Codeforces Round #247 (Div. 2) B - Shower Line,布布扣,bubuko.com

Codeforces Round #247 (Div. 2) B - Shower Line

标签:style   class   blog   code   ext   color   

原文地址:http://www.cnblogs.com/xiongqiangcs/p/3786325.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!