Submission #746484

#TimeUsernameProblemLanguageResultExecution timeMemory
746484nguyentunglamBubble Sort 2 (JOI18_bubblesort2)C++17
60 / 100
6363 ms12828 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 1e5 + 01; int f[N]; vector<int> countScans(vector<int> a, vector<int> pos, vector<int> val) { vector<int> ans(pos.size()); int n = a.size(); for(int j = 0; j < n; j++) for(int k = 0; k < j; k++) f[j] += (a[j] < a[k]); for(int i = 0; i < pos.size(); i++) { int idx = pos[i]; for(int j = idx + 1; j < n; j++) f[j] -= (a[j] < a[idx]); a[idx] = val[i]; for(int j = idx + 1; j < n; j++) f[j] += (a[j] < a[idx]); f[idx] = 0; for(int j = 0; j < idx; j++) f[idx] += (a[idx] < a[j]); for(int j = 0; j < n; j++) ans[i] = max(ans[i], f[j]); } return ans; } #ifdef ngu int main() { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); int n, q; cin >> n >> q; vector<int> a(n), x(q), v(q); for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < q; i++) cin >> x[i] >> v[i]; vector<int> ret = countScans(a, x, v); for(int &j : ret) cout << j << endl; } #endif // ngu

Compilation message (stderr)

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 0; i < pos.size(); 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...