Submission #894667

#TimeUsernameProblemLanguageResultExecution timeMemory
894667lunaTuBubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
9067 ms2060 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ff first #define ss second #define all(x) x.begin(), x.end() #include "bubblesort2.h" typedef long long ll; using namespace std; using namespace __gnu_pbds; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int N = 5e4 + 1; int A[N]; int ans[N]; int add(int n, int i, int x) { int mx = 0; for (int j = i + 1; j < n; j++) { if (A[j] < A[i]) ans[j]--; if (A[j] < x) ans[j]++; mx = max(mx, ans[j]); } ans[i] = 0; for (int j = i - 1; j >= 0; j--) { if (A[j] > x) ans[i]++; mx = max(mx, ans[j]); } A[i] = x; return max(mx, ans[i]); } vector<int> countScans(vector<int> a, vector<int> x, vector<int> v){ int n = a.size(); for (int i = 0; i < n; i++) { int w = add(n, i, a[i]); } int q = x.size(); vector<int> answer(q); for (int j = 0; j < q; j++) answer[j] = add(n, x[j], v[j]); return answer; }

Compilation message (stderr)

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:47:13: warning: unused variable 'w' [-Wunused-variable]
   47 |         int w = add(n, i, a[i]);
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...