zoukankan      html  css  js  c++  java
  • 洛谷:P1130 红牌

    #include<iostream>
    #include<algorithm>
    #include<string>
    #define min(a,b) ((a)<(b)?(a):(b))
    using namespace std;
    int input[2005][2005];
    int X,Y;
    int main() {
        cin>>X>>Y;
        for(int i=0;i<Y;i++)
            for(int j=0;j<X;j++)
                cin>>input[i][j];
        for(int j=X-2;j>=0;j--)
            for(int i=0;i<Y;i++)
                input[i][j]=min(input[(i+1)%Y][j+1],input[i][j+1])+input[i][j];
        if(0){
            for(int i=0;i<Y;i++){
                for(int j=0;j<X;j++){
                    cout<<input[i][j]<<" ";
                }
                cout<<endl;
            }
        }
        int tmin=input[0][0];
    
        for(int i=1;i<Y;i++){
            tmin=min(tmin,input[i][0]);
        }
        cout<<tmin;
        return 0;
    }

    https://www.luogu.com.cn/problem/P1130

  • 相关阅读:
    hihocoder 1038
    hihocoder 1039
    poj 2774
    bzoj 4690&&4602
    poj 2417
    STL
    poj 1026
    poj 1064
    poj 1861(prim)
    poj 1129
  • 原文地址:https://www.cnblogs.com/forwhat00/p/13245918.html
Copyright © 2011-2022 走看看