답안 #1013626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013626 2024-07-03T17:44:10 Z vjudge1 Bubble Sort 2 (JOI18_bubblesort2) C++17
17 / 100
9000 ms 3412 KB
#include <bits/stdc++.h>
#define mod 1000000007LL
#define inf 1e17
#define ll long long
using namespace std;

void printvec(vector<int> vec)
{
    for (auto &&e : vec)
    {
        cout << e << ' ';
    }
    cout << endl;
}

vector<int> countScans(vector<int> a, vector<int> x, vector<int> v)
{
    vector<int> s;
    multiset<int> a_sorted;
    for (int i = 0; i < a.size(); i++)
    {
        a_sorted.insert(a[i]);
    }
    for (int j = 0; j < x.size(); j++)
    {
    a_sorted.erase(a_sorted.find(a[x[j]]));
    a_sorted.insert(v[j]);
    a[x[j]] = v[j];
    // for (auto& e:a_sorted) cout << e << ' ';
    // cout << endl;
    map<ll,ll> ind;
    ll i = 0;
    for (auto it = a_sorted.begin(); it != a_sorted.end(); it++)
    {
        ind[*it] = i;
        i++;
    }
    ll maxe = 0;
    for (int i = 0; i < a.size(); i++)
    {
        if(i > ind[a[i]])
        {
            maxe = max(maxe, i - ind[a[i]]);
        }
    }
    s.push_back(maxe);
    }
    return s;
}

// int main()
// {
//     vector<int> A = {1, 2, 3, 4};
//     vector<int> X = {0, 2};
//     vector<int> V = {3, 1};
//     vector<int> ans = countScans(A,X,V);
//     printvec(ans);
// }

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
bubblesort2.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int j = 0; j < x.size(); j++)
      |                     ~~^~~~~~~~~~
bubblesort2.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 600 KB Output is correct
2 Correct 97 ms 344 KB Output is correct
3 Correct 652 ms 728 KB Output is correct
4 Correct 658 ms 728 KB Output is correct
5 Correct 662 ms 980 KB Output is correct
6 Correct 588 ms 744 KB Output is correct
7 Correct 617 ms 848 KB Output is correct
8 Correct 597 ms 724 KB Output is correct
9 Correct 604 ms 740 KB Output is correct
10 Correct 491 ms 860 KB Output is correct
11 Correct 485 ms 600 KB Output is correct
12 Correct 494 ms 604 KB Output is correct
13 Correct 514 ms 736 KB Output is correct
14 Correct 493 ms 600 KB Output is correct
15 Correct 487 ms 700 KB Output is correct
16 Correct 492 ms 732 KB Output is correct
17 Correct 488 ms 600 KB Output is correct
18 Correct 519 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 600 KB Output is correct
2 Correct 97 ms 344 KB Output is correct
3 Correct 652 ms 728 KB Output is correct
4 Correct 658 ms 728 KB Output is correct
5 Correct 662 ms 980 KB Output is correct
6 Correct 588 ms 744 KB Output is correct
7 Correct 617 ms 848 KB Output is correct
8 Correct 597 ms 724 KB Output is correct
9 Correct 604 ms 740 KB Output is correct
10 Correct 491 ms 860 KB Output is correct
11 Correct 485 ms 600 KB Output is correct
12 Correct 494 ms 604 KB Output is correct
13 Correct 514 ms 736 KB Output is correct
14 Correct 493 ms 600 KB Output is correct
15 Correct 487 ms 700 KB Output is correct
16 Correct 492 ms 732 KB Output is correct
17 Correct 488 ms 600 KB Output is correct
18 Correct 519 ms 716 KB Output is correct
19 Execution timed out 9074 ms 1528 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2852 ms 1880 KB Output is correct
2 Execution timed out 9063 ms 3412 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 600 KB Output is correct
2 Correct 97 ms 344 KB Output is correct
3 Correct 652 ms 728 KB Output is correct
4 Correct 658 ms 728 KB Output is correct
5 Correct 662 ms 980 KB Output is correct
6 Correct 588 ms 744 KB Output is correct
7 Correct 617 ms 848 KB Output is correct
8 Correct 597 ms 724 KB Output is correct
9 Correct 604 ms 740 KB Output is correct
10 Correct 491 ms 860 KB Output is correct
11 Correct 485 ms 600 KB Output is correct
12 Correct 494 ms 604 KB Output is correct
13 Correct 514 ms 736 KB Output is correct
14 Correct 493 ms 600 KB Output is correct
15 Correct 487 ms 700 KB Output is correct
16 Correct 492 ms 732 KB Output is correct
17 Correct 488 ms 600 KB Output is correct
18 Correct 519 ms 716 KB Output is correct
19 Execution timed out 9074 ms 1528 KB Time limit exceeded
20 Halted 0 ms 0 KB -