1 条题解

  • 0
    @ 2021-6-15 1:39:58

    C++ :

    #include <iostream>
    #include <algorithm>
    using namespace std;
    
    const int N = 507;
    int G[N][N];
    
    int main()
    {
    	int n, i, j, Res = 0, c;
    	
    	cin >> n;
    	for (i = 1; i < n; ++i)
    		for (j = i + 1; j <= n; ++j) {cin >> c; G[i][j] = G[j][i] = c;}
    	
    	for (i = 1; i <= n; ++i) sort(G[i] + 1, G[i] + n + 1, greater<int>());
    	for (i = 1; i <= n; ++i) Res = max(Res, G[i][2]);
    	
    	cout << 1 << endl << Res << endl;
    	
    	return 0;
    }
    
    

    Pascal :

    var  n,i,j:1..500;
         a,b,c:longint;
         mqz:array[1..500,1..500]of longint;
    begin
      readln(n);
      for i:=1 to n-1 do
        begin
          for j:=i+1 to n do
            begin
              read(mqz[i,j]);
              mqz[j,i]:=mqz[i,j];
            end;
          readln;
        end;
      for i:=1 to n do
        begin
          b:=0;
          c:=0;
          for j:=1 to n do
            if mqz[i,j]>b
              then
                begin
                  c:=b;
                  b:=mqz[i,j];
                end
              else
                if mqz[i,j]>c then c:=mqz[i,j];
          if c>a then a:=c;
        end;
      writeln(1);
      writeln(a);
    end.
    
    • 1

    信息

    ID
    279
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者