Submission #854020

#TimeUsernameProblemLanguageResultExecution timeMemory
854020RifalBubble Sort 2 (JOI18_bubblesort2)C++14
38 / 100
429 ms1104 KiB
#include "bubblesort2.h" #include<bits/stdc++.h> using namespace std; vector<int> countScans(vector<int> A,vector<int> X,vector<int> V){ vector<int> answer; int siz = A.size(), cnt[siz] = {}; for(int i = 0; i < siz; i++) { int sum = 0; for(int j = 0; j < i; j++) { if(A[j] < A[i]) sum++; } cnt[i] = sum; } for(int i = 0; i < X.size(); i++) { int sum = 0, ans = 0; for(int j = 0; j < X[i]; j++) { if(A[j] < V[i]) sum++; } for(int j = X[i]+1; j < siz; j++) { if(A[X[i]] < A[j]) cnt[j]--; if(V[i] < A[j]) cnt[j]++; } cnt[X[i]] = sum; A[X[i]] = V[i]; for(int j = 0; j < siz; j++) { ans = max(ans,j-cnt[j]); } answer.push_back(ans); } return answer; }

Compilation message (stderr)

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