Resumen de la simulación el día 16

El k-ésimo entero
# incluye el
uso del espacio de nombres std;
int n, a [20000], ans [40000] = {}, b [20000] = {};
int main ()
{ int h, k = 0; scanf ("% d % d ", & n, & h); para (int i = 1; i <= n; i ++) { scanf ("% d ", & a [i]); } para (int i = 1; i <= n; i ++) { ans [a [i]] ++; } for (int i = 1; i <= 39999; i ++) { if (ans [i]! = 0) { k ++; // K ++ en este lugar Ponlo adentro, de lo contrario no tendrá sentido b [k] = i;











	}
}
if(h <= k){
	printf("%d" ,b[h]);
}
else{
	printf("NO  RESULT");   //两个空格
}
return 0;

}
Scholarship
#include
#include
using namespace std;
struct stu { int tot, id, chi, eng, mat; } st [10001]; bool compare (stu x, stu y) { if (x.tot! = Y.tot ) return x.tot> y.tot; if (x.chi! = y.chi) return x.chi> y.chi; // Aquí tenemos que determinar si los idiomas son iguales; de lo contrario, el id a continuación no tiene efecto return x.id <y.id; } int n; int main () { scanf ("% d", & n); for (int i = 1; i <= n; i ++) { scanf ("% d% d% d ", & st [i] .chi, & st [i] .mat, & st [i] .eng); st [i] .id = i; st [i] .tot = st [i]. chi + st [i] .mat + st [i] .eng; } sort (st + 1, st + 1 + n, comparar); para (int i = 1; i <= 5; i ++) {


















printf ("% d% d \ n", st [i] .id, st [i] .tot);
}
return 0;
} Los
soldados hacen fila.
Creo que esto sigue siendo codicioso, solo encuentra la mediana
#include
# incluir
#include
usando el espacio de nombres std;
int main () { int n; int a [20001] = {}, b [20001] = {}; scanf ("% d", & n); int place, toty = 0, totx = 0; para (int i = 1; i <= n; i ++) { scanf ("% d% d", & b [i], & a [i]); } sort (a + 1, a + 1 + n ); if (n% 2 == 0) place = n / 2; else place = (n + 1) / 2; for (int i = 1; i <= n; i ++) { toty = toty + abs (a [i] -a [lugar]); } sort (b + 1, b + 1 + n); for (int i = 1; i <= n; i ++) {















b [i] = b [i] -i + 1; // x no se mueve a un punto fijo, así que primero preprocese x usando reglas para encontrar el punto medio correcto
}
sort (b + 1, b + 1 + n);

for(int i = 1;i <= n; i++){
	totx = totx + abs(b[i] - b[place]); 
}
int tot = totx + toty;
printf("%d" ,tot);
return 0;

}
Estadísticas
#include
#include
using namespace std;
int n, biaoji = 0;
int un [200,005]; // Al principio se redujo la matriz, y 4 Los datos fueron directamente pegado
tiempo int;
int main ()
{ scanf ( "% d ", & n); for (int i = 0; i <n; i ++) { scanf ("% d ", & a [i]); } sort (a, a + n); time = 1; for (int i = 1; i <n; i ++) {/ if (a [i-1]! = a [i]) { printf ("% d% d \ n", a [i-1], tiempo); tiempo = 1; } else { time ++; } } printf ("% d% d", a [n-1], time); return 0; } Mode #include using namespace std; long long int n;






















long long int a [40000];
long long int ans [40000] = {};
long long int max = 0;
int main () { scanf ("% lld", & n); for (int i = 1; i <= n; i ++) { scanf ("% lld", & a [i]); } para (int i = 1; i <= n; i ++) { ans [a [i]] ++; } para (int i = 1; i <= 30000; i ++) {// 桶 排 , 最大 的 数 有 多大 i 就要 循环 到哪 , 别忘 了if (ans [i]> max) { max = ans [ yo]; } } for (int i = 1; i <= 30000; i ++) { if (ans [i] == max) { printf ("% d% d \ n", i, max); } } return 0; }


















Supongo que te gusta

Origin blog.csdn.net/Skywalker_____/article/details/112738337
Recomendado
Clasificación