1 solutions

  • 0
    @ 2025-11-5 20:02:26

    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

    Information

    ID
    19964
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By