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

Envío 2052

Problema 0xde - Ordenar un arreglo grande

  • Autor: S8Vega
  • Fecha: 2020-11-20 04:17:31 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.006 s 1 KBi
#2
Correcto
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.006 s 1 KBi
#3
Correcto
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.006 s 1 KBi
#4
Correcto
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.005 s 1 KBi
#5
Correcto
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.006 s 1 KBi
#6
Correcto
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.005 s 1 KBi
#7
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#8
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#9
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#10
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#11
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#12
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#13
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#14
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#15
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#16
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#17
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#18
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#19
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#20
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#21
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#22
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.005 s 1 KBi
#23
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#24
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#25
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#26
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#27
Error en tiempo de ejecución (NZEC)
                      main.cpp:70:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
Puntos totales: 23 / 100

Código

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

const int N = 1010;
int n, arr[N];

void merge(int l, int m, int r) {
  int n1 = m - l + 1;
  int n2 = r - m;
  int L[n1], R[n2];
  for (int i = 0; i < n1; i++) L[i] = arr[l + i];
  for (int j = 0; j < n2; j++) R[j] = arr[m + 1 + j];
  int i = 0;
  int j = 0;
  int k = l;
  while (i < n1 && j < n2) {
    if (L[i] <= R[j]) {
      arr[k] = L[i];
      i++;
    } else {
      arr[k] = R[j];
      j++;
    }
    k++;
  }
  while (i < n1) {
    arr[k] = L[i];
    i++;
    k++;
  }
  while (j < n2) {
    arr[k] = R[j];
    j++;
    k++;
  }
}

void mergeSort(int l, int r) {
  if (l >= r) {
    return;
  }
  int m = (l + r - 1) / 2;
  mergeSort(l, m);
  mergeSort(m + 1, r);
  merge(l, m, r);
}

int main() {
#ifdef LOCAL
  freopen("a.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  mergeSort(0, n - 1);
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " \n"[i + 1 == n];
  }
  return 0;
}