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

模拟即可

#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

时间: 2024-10-21 02:28:12

Codeforces Round #247 (Div. 2) B - Shower Line的相关文章

Codeforces Round #247 (Div. 2) ABC

Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431 代码均已投放:https://github.com/illuz/WayToACM/tree/master/CodeForces/431 A - Black Square 题目地址 题意: Jury玩别踩白块,游戏中有四个区域,Jury点每个区域要消耗ai的卡路里,给出踩白块的序列,问要消耗多少卡路里. 分析: 模拟水题.. 代码: /* * Author: illuz

Codeforces Round #247 (Div. 2)

A.水题. 遍历字符串对所给的对应数字求和即可. B.简单题. 对5个编号全排列,然后计算每种情况的高兴度,取最大值. C.dp. 设dp[n][is]表示对于k-trees边和等于n时,如果is==1表示存在边至少为d的边,如果is==0表示不存在边至少为d的边. 初始状态dp[0][0]=1. //和为n且不存在至少为d的边的状态可以由所有不存在至少为d的边加一条小于d的边转移而来. dp[n][0]=dp[n-1][0]+dp[n-2][0]+--+dp[n-(d-1)][0] //和为n

Codeforces Round #247 (Div. 2) C. k-Tree

题目链接:http://codeforces.com/problemset/problem/431/C 题意:给一个k-tree,每个节点有k个儿子,然后边权从左到右依次为1-k,给定n, k, d, 求至少有一条边权值>=d然后总和是n有多少种方法 题解:dp[i][j][0]表示当前到第i层,和为j,没有超过d的边权的方法数,dp[i][j][1]表示当前到第i层,和为j,有超过d的边权的方法数. #include <cstdio> #include <cstring>

Codeforces Round #153 (Div. 1)APoints on Line

#include<cstdio> #include<cstring> #include<iostream> using namespace std ; const int maxn  = 100010 ; int a[maxn] ; int bit(int l , int r ,int num) { while(l <= r) { int mid = (l + r) >> 1; if(a[mid] <= num) l = mid + 1 ; el

Codeforces Round #247 (Div. 2) C. k-Tree (dp)

题目链接 题意: 思路: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 using namespace std; 7 const int mo = 1000000000 + 7; 8 int dp[110][110][110]; 9 10 int main() 11 { 12

Codeforces Round #247 (Div. 2) C D

这题是一个背包问题 这样的 在一个k子树上 每个节点都有自己的k个孩子 然后 从原点走 走到 某个点的 和为 N 且每条的 长度不小于D 就暂停问这样的 路有多少条,  呵呵 想到了 这样做没有把他敲出来,可以很清楚的 到达第几层都能到达那些状态 然后 最多N层看看每层取到什么样的值 然后先算出没有任何限制 的路有多少条 接着用权值小于D的路径做看能够搞多少条 然后相减一下就好了 #include <cstdio> #include <string.h> #include <

Codeforces Round #339 (Div. 2) B. Gena&#39;s Code

B. Gena's Code It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, f

Codeforces Round #315 (Div. 1)

A. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and un

Codeforces Round #275 (Div. 1)A. Diverse Permutation 构造

Codeforces Round #275 (Div. 1)A. Diverse Permutation Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/482/problem/A Description Permutation p is an ordered set of integers p1,   p2,   ...,   pn, consisting of n distinct posi