답안 #277937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
277937 2020-08-21T08:10:13 Z Revo7 Bubble Sort 2 (JOI18_bubblesort2) C++14
22 / 100
121 ms 4980 KB
#include "bubblesort2.h"
#include<bits/stdc++.h>
#define pb push_back

using namespace std;

vector<int> countScans(vector<int> a,vector<int> pos,vector<int> v){
    set<int>s[111];

    for(int i=0;i<a.size();i++){
        s[a[i]].insert(i);
    }
    vector<int>ans;

    for(int i=0;i<pos.size();i++){
        //cout<<i<<endl;
        int mx=0,id=pos[i],newval=v[i];
        s[a[id]].erase(id);
        a[id]=newval;
        s[newval].insert(id);
        int cur=0;
        for(int j=1;j<=100;j++){
            cur+=s[j].size();
            if(s[j].size())
            mx=max(mx,*s[j].rbegin()-cur+1);
        }
        ans.pb(mx);
    }
	return ans;
}
/*
4 2
1 2 3 4
0 3
2 1
*/

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
bubblesort2.cpp:15:18: 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++){
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1920 KB Output is correct
2 Correct 51 ms 3448 KB Output is correct
3 Correct 107 ms 4856 KB Output is correct
4 Correct 105 ms 4788 KB Output is correct
5 Correct 97 ms 4856 KB Output is correct
6 Correct 107 ms 4856 KB Output is correct
7 Correct 96 ms 4856 KB Output is correct
8 Correct 121 ms 4776 KB Output is correct
9 Correct 120 ms 4844 KB Output is correct
10 Correct 104 ms 4900 KB Output is correct
11 Correct 100 ms 4928 KB Output is correct
12 Correct 114 ms 4980 KB Output is correct
13 Correct 110 ms 4856 KB Output is correct
14 Correct 93 ms 4880 KB Output is correct
15 Correct 86 ms 4908 KB Output is correct
16 Correct 79 ms 4888 KB Output is correct
17 Correct 65 ms 4876 KB Output is correct
18 Correct 69 ms 4924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -