답안 #363266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363266 2021-02-05T12:02:53 Z NEvOl Bubble Sort 2 (JOI18_bubblesort2) C++14
0 / 100
80 ms 876 KB
#include "bubblesort2.h"
#include <algorithm>

using namespace std;

int get_cnt(vector<int> curr)
{
    int cnt = 0;
    int mn = curr[curr.size() - 1];
    for(int i = curr.size() - 2; -1 < i; i--)
    {
        if(mn < curr[i])
            cnt++;
        mn = min(mn, curr[i]);
    }    
    return cnt;
}

std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
	int Q=X.size();
	std::vector<int> answer(Q);
    vector<int> curr(A.size());
    for(int i = 0; i < A.size(); i++)
        curr[i] = A[i];
    int cnt = get_cnt(curr);

	for (int j=0;j<Q;j++) {
        curr[X[j]] = V[j];        
		answer[j]=get_cnt(curr);
	}
	return answer;
}

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < A.size(); i++)
      |                    ~~^~~~~~~~~~
bubblesort2.cpp:25:9: warning: unused variable 'cnt' [-Wunused-variable]
   25 |     int cnt = get_cnt(curr);
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 80 ms 876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -