█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 7208

Problema 0xcf - Mirando al horizonte

  • Autor: Prueba
  • Fecha: 2023-11-26 03:59:51 UTC (Hace 6 meses)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#2
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#3
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#4
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#5
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#6
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#7
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#8
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#9
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
#10
Error de compilación
                      main.c:1:1: error: unknown type name 'using'
using System;
^
main.c:2:1: error: unknown type name 'using'
using System.Collections.Generic;
^
main.c:2:13: error: expected ';' after top level declarator
using System.Collections.Generic;
            ^
            ;
main.c:4:1: error: unknown type name 'class'
class Program
^
main.c:4:14: error: expected ';' after top level declarator
class Program
             ^
             ;
5 errors generated.

                    
Puntos totales: 0 / 100

Código

using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int cases = int.Parse(Console.ReadLine());
        for (int c = 1; c <= cases; ++c)
        {
            Console.Write("Case #" + c + ":");
            Solve();
        }
    }

    static void Solve()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        for (int i = 0; i < n; ++i)
        {
            a[i] = int.Parse(Console.ReadLine());
        }
        LinkedList<int> q = new LinkedList<int>();
        int[] answer = new int[n];
        for (int i = n - 1; i >= 0; --i)
        {
            while (q.Count > 0 && a[i] >= q.First.Value)
            {
                q.RemoveFirst();
            }
            answer[i] = q.Count == 0 ? -1 : q.First.Value;
            q.AddFirst(a[i]);
        }
        for (int i = 0; i < n; ++i)
        {
            Console.Write(" " + answer[i]);
        }
        Console.WriteLine();
    }
}