Submission #28403747


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

tree<int,null_type,greater<int>,rb_tree_tag, tree_order_statistics_node_update> s;

int main(){
  int n,k;
  cin>>n>>k;

  while(n--){
    int v;
    cin>>v;
    s.insert(v);

    if(s.size()>=k){
      cout<<*s.find_by_order(k-1)<<"\n";
    }
  }
}

Submission Info

Submission Time
Task D - Prefix K-th Max
User Mitsubachi
Language C++ (GCC 9.2.1)
Score 400
Code Size 425 Byte
Status AC
Exec Time 1227 ms
Memory 27452 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:16: warning: comparison of integer expressions of different signedness: ‘__gnu_pbds::detail::bin_search_tree_set<int, __gnu_pbds::null_type, std::greater<int>, __gnu_pbds::detail::tree_traits<int, __gnu_pbds::null_type, std::greater<int>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
   19 |     if(s.size()>=k){
      |        ~~~~~~~~^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 28
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 10 ms 3528 KiB
001.txt AC 1227 ms 27368 KiB
002.txt AC 323 ms 27016 KiB
003.txt AC 745 ms 27044 KiB
004.txt AC 915 ms 26972 KiB
005.txt AC 775 ms 25556 KiB
006.txt AC 554 ms 15456 KiB
007.txt AC 1095 ms 26428 KiB
008.txt AC 295 ms 13232 KiB
009.txt AC 380 ms 13400 KiB
010.txt AC 1177 ms 27252 KiB
011.txt AC 1155 ms 27452 KiB
012.txt AC 351 ms 26852 KiB
013.txt AC 354 ms 27044 KiB
014.txt AC 756 ms 27012 KiB
015.txt AC 746 ms 26880 KiB
016.txt AC 757 ms 26896 KiB
017.txt AC 743 ms 26968 KiB
018.txt AC 1154 ms 27448 KiB
019.txt AC 1202 ms 27396 KiB
020.txt AC 341 ms 26972 KiB
021.txt AC 363 ms 27016 KiB
022.txt AC 744 ms 26968 KiB
023.txt AC 781 ms 26976 KiB
024.txt AC 747 ms 27084 KiB
025.txt AC 775 ms 26968 KiB
example0.txt AC 6 ms 3592 KiB
example1.txt AC 2 ms 3540 KiB