Submission #496054

# Submission time Handle Problem Language Result Execution time Memory
496054 2021-12-20T13:44:44 Z 600Mihnea Bubble Sort 2 (JOI18_bubblesort2) C++17
17 / 100
9000 ms 2372 KB
#include "bubblesort2.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



vector<int> innterCountScans(vector<ll> a, vector<int> pos, vector<ll> value) {
  int n = (int) a.size();
  int q = (int) pos.size();

  for (int i = 0; i < n; i++) {
    a[i] = a[i] * (ll) (n + 1) + i;
  }

  assert(q == (int) value.size());

  for (int it = 0; it < q; it++) {
    value[it] = value[it] * (ll) (n + 1) + pos[it];
  }

  vector<int> sol;

  for (int it = 0; it < q; it++) {
    a[pos[it]] = value[it];

    ll MN = a[n - 1];
    int MX = 0;
    for (int i = n - 1; i >= 0; i--) {
      MN = min(MN, a[i]);
      if (a[i] == MN) {
        int bigger = 0;
        for (int j = 0; j < i; j++) {
          if (a[j] > a[i]) {
            bigger++;
          }
        }
        /// a[i] = minim pe sufix => (a[i] - 1)
        MX = max(MX, bigger);
      }
    }
    sol.push_back(MX);
  }

  return sol;
}


vector<int> countScans(vector<int> a, vector<int> b, vector<int> c) {
  vector<ll> X, Z;
  for (auto &it : a) {
    X.push_back(it);
  }
  for (auto &it : c) {
    Z.push_back(it);
  }
  return innterCountScans(X, b, Z);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 26 ms 468 KB Output is correct
4 Correct 38 ms 460 KB Output is correct
5 Correct 316 ms 576 KB Output is correct
6 Correct 2609 ms 460 KB Output is correct
7 Correct 1995 ms 460 KB Output is correct
8 Correct 1428 ms 460 KB Output is correct
9 Correct 253 ms 460 KB Output is correct
10 Correct 2133 ms 440 KB Output is correct
11 Correct 2209 ms 440 KB Output is correct
12 Correct 2214 ms 444 KB Output is correct
13 Correct 2209 ms 440 KB Output is correct
14 Correct 2327 ms 456 KB Output is correct
15 Correct 2256 ms 440 KB Output is correct
16 Correct 2224 ms 448 KB Output is correct
17 Correct 2223 ms 444 KB Output is correct
18 Correct 2165 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 26 ms 468 KB Output is correct
4 Correct 38 ms 460 KB Output is correct
5 Correct 316 ms 576 KB Output is correct
6 Correct 2609 ms 460 KB Output is correct
7 Correct 1995 ms 460 KB Output is correct
8 Correct 1428 ms 460 KB Output is correct
9 Correct 253 ms 460 KB Output is correct
10 Correct 2133 ms 440 KB Output is correct
11 Correct 2209 ms 440 KB Output is correct
12 Correct 2214 ms 444 KB Output is correct
13 Correct 2209 ms 440 KB Output is correct
14 Correct 2327 ms 456 KB Output is correct
15 Correct 2256 ms 440 KB Output is correct
16 Correct 2224 ms 448 KB Output is correct
17 Correct 2223 ms 444 KB Output is correct
18 Correct 2165 ms 444 KB Output is correct
19 Correct 304 ms 1016 KB Output is correct
20 Correct 481 ms 1088 KB Output is correct
21 Execution timed out 9032 ms 972 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6625 ms 1184 KB Output is correct
2 Execution timed out 9088 ms 2372 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 26 ms 468 KB Output is correct
4 Correct 38 ms 460 KB Output is correct
5 Correct 316 ms 576 KB Output is correct
6 Correct 2609 ms 460 KB Output is correct
7 Correct 1995 ms 460 KB Output is correct
8 Correct 1428 ms 460 KB Output is correct
9 Correct 253 ms 460 KB Output is correct
10 Correct 2133 ms 440 KB Output is correct
11 Correct 2209 ms 440 KB Output is correct
12 Correct 2214 ms 444 KB Output is correct
13 Correct 2209 ms 440 KB Output is correct
14 Correct 2327 ms 456 KB Output is correct
15 Correct 2256 ms 440 KB Output is correct
16 Correct 2224 ms 448 KB Output is correct
17 Correct 2223 ms 444 KB Output is correct
18 Correct 2165 ms 444 KB Output is correct
19 Correct 304 ms 1016 KB Output is correct
20 Correct 481 ms 1088 KB Output is correct
21 Execution timed out 9032 ms 972 KB Time limit exceeded
22 Halted 0 ms 0 KB -