Submission #235166

#TimeUsernameProblemLanguageResultExecution timeMemory
235166AtalasionBubble Sort 2 (JOI18_bubblesort2)C++14
0 / 100
2823 ms992 KiB
//khodaya khodet komak kon #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define all(x) x.begin(), x.end() #pragma GCC optimize ("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize ("-O2") using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int N = 500000 + 10; const ll MOD = 1000000000 + 7; const ll INF = 1000000010; const ll LOG = 25; int a[N], n, q, cnt[N]; vector<int> countScans(vi A, vi X, vi V){ n = A.size(); q = X.size(); for (int i = 1; i <= n; i++){ a[i] = A[i - 1]; } for (int i = 1; i <= n; i++) for (int j = 1; j < n; j++) if (a[j] > a[i]) cnt[i]++; vector<int> res; for (int i = 0; i < q; i++){ for (int j = X[i] + 1; j <= n; j++)if(a[X[i]] > a[j]) cnt[j]--; cnt[X[i]] = 0; a[X[i]] = V[i]; for(int j = 1; j < X[i]; j++) if (a[j] > V[i]) cnt[X[i]]++; for (int j = X[i] + 1; j <= n; j++) if (V[i] > a[j]) cnt[j]++; int mx = 0; for( int j = 1; j <= n; j++) mx = max(mx, cnt[j]); res.pb(mx); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...