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

Envío 6448

Problema 0x62 - Contar elementos mayores a X en un arreglo pequeño

  • Autor: bernalcodes
  • Fecha: 2022-07-06 17:37:29 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#2
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#3
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#4
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#5
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#6
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#7
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#8
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#9
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
#10
Error de compilación
                      main.cpp:19:24: error: expected ';' in 'for' statement specifier
                for (int i = 0; i < n) {
                                     ^
main.cpp:27:12: error: expected '}'
        return 0;       
                        ^
main.cpp:4:16: note: to match this '{'
int main(void) {
               ^
2 errors generated.

                    
Puntos totales: 0 / 100

Código

#include <iostream>
using namespace std;

int main(void) {
	int n;
	cin>>n;
	
	long long a[n];
	for (int i = 0; i < n; i++) {
		cin>>a[i];
	}
	
	int q;
	cin>>q;
	long long p;
	for (int i = 0; i < q; i++) {
		cin>>p;
		int count = 0;
		for (int i = 0; i < n) {
			if (a[i] > p) {
				count++;
			}
		}
		cout<<count<<endl;
	}
	
	return 0;