codeforces-102A Clothes(暴力)

原创 2018年04月16日 20:55:28

链接:http://codeforces.com/problemset/problem/102/A
题意:给定n件衣服,每件衣服有价格,有m中配对关系,求最小的价格从中选取三件衣服,使得它们之间能两两配对

题解:n很小直接暴力

#include<iostream>
#include<cstring>
#include<map>
#include<cstdio>
#include<algorithm>
using namespace std;

int n, m;
int ma[110][110];
int a[110];

int main(){
    cin>>n>>m;
    for(int i = 1; i<=n; i++) cin>>a[i];
    for(int i = 1; i<=m; i++){
        int u, v;
        cin>>u>>v;
        ma[u][v] = ma[v][u] = 1;
    }
    int res = 0x3f3f3f3f;
    for(int i = 1; i<=n; i++){
        for(int j = i+1; j<=n; j++){
            for(int k = j+1; k<=n; k++){
                if(ma[i][j] && ma[j][k] && ma[i][k]) res = min(res, a[i]+a[j]+a[k]);
            }
        }
    }

    if(res == 0x3f3f3f3f){
        cout<<"-1"<<endl;
    }
    else cout<<res<<endl;

    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/GrimCake/article/details/79966364

交互设计指南(二)

1       前言2       总体要求2.6   键盘响应对于模式窗口,要求其能够响应回车键和取消(Escape)键:2.6.1                回车键回车键:表示确认,执行保存/...
  • Musicwind
  • Musicwind
  • 2004-05-22 21:28:00
  • 1372

CodeForces 102A

#include #include #include #include using namespace std; struct node {     int id...
  • u013570474
  • u013570474
  • 2014-04-10 18:35:37
  • 286

How to wear clothes

  • 2013年06月15日 19:21
  • 961KB
  • 下载

论文阅读理解 - DeepFashion: Powering Robust Clothes Recognition and Retrieval with Rich Annotations

DeepFashion: Powering Robust Clothes Recognition and Retrieval with Rich Annotations [Paper] [Proj...
  • oJiMoDeYe12345
  • oJiMoDeYe12345
  • 2017-10-24 13:51:59
  • 1213

DeepFashion: Powering Robust Clothes Recognition and Retrieval with Rich Annotations – CVPR 2016

DeepFashion: Powering Robust ClothesRecognition and Retrieval with Rich Annotations – CVPR 2016 论文...
  • xuanyoumeng
  • xuanyoumeng
  • 2016-07-03 21:49:17
  • 4737

POJ 3104 Drying(二分搜索,最大化最小值)

Drying Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11464   Accept...
  • zwj1452267376
  • zwj1452267376
  • 2015-12-10 13:31:53
  • 1033

论文理解:DeepFashion: Powering Robust Clothes Recognition and Retrieval with Rich Annotations

本文为香港中文大学与熵汤联合出品的一篇CVPR。获取链接:http://www.ee.cuhk.edu.hk/~xgwang/papers/liuLQWTcvpr16.pdf 主要包含两个工作: ...
  • fuwenyan
  • fuwenyan
  • 2017-10-12 11:26:56
  • 532

POJ3104:Drying(二分)

Description It is very hard to wash and especially to dry clothes in winter. But Jane is a very s...
  • libin56842
  • libin56842
  • 2014-08-17 16:31:09
  • 1948

【vector】#79 A. Clothes

A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes ...
  • okcd00
  • okcd00
  • 2014-11-29 18:35:06
  • 555

POJ3104 Drying (二分的力量2)

 Description It is very hard to wash and especially to dry clothes in winter. But Jane is ...
  • sunny1996
  • sunny1996
  • 2015-04-12 21:52:41
  • 566
收藏助手
不良信息举报
您举报文章:codeforces-102A Clothes(暴力)
举报原因:
原因补充:

(最多只允许输入30个字)