Submission #28413016


Source Code Expand

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){

    int K, N, p, a = 0;
    vector<int> A;
    cin >> N >> K;
    for (int i=0; i<N; i++){
        cin >> p;

        if (i < K-1) {
            A.push_back(p);
        } else if (i == K-1){
            A.push_back(p);
            sort(A.begin(), A.end(), greater<int>());
            a = A[K-1];
            cout << A[K-1] << endl;
        } else {
            if (p < a) {
                cout << a << endl;
            } else if (a == N-K+1) {
                cout << a << endl;
            } else {
                A.push_back(p);
                sort(A.begin(), A.end(), greater<int>());
                a = A[K-1];
                cout << A[K-1] << endl;
            }
        }
    }
    return 0;
}

Submission Info

Submission Time
Task D - Prefix K-th Max
User gackel
Language C++ (Clang 10.0.0)
Score 0
Code Size 871 Byte
Status TLE
Exec Time 2205 ms
Memory 4960 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 2
AC × 14
TLE × 14
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 9 ms 3156 KiB
001.txt AC 1097 ms 3988 KiB
002.txt AC 305 ms 4960 KiB
003.txt TLE 2205 ms 4172 KiB
004.txt TLE 2205 ms 3780 KiB
005.txt TLE 2205 ms 3792 KiB
006.txt AC 755 ms 3112 KiB
007.txt TLE 2205 ms 3268 KiB
008.txt TLE 2205 ms 3480 KiB
009.txt TLE 2205 ms 3428 KiB
010.txt TLE 2205 ms 3300 KiB
011.txt AC 1072 ms 3956 KiB
012.txt AC 242 ms 4852 KiB
013.txt AC 246 ms 4848 KiB
014.txt TLE 2205 ms 4080 KiB
015.txt AC 667 ms 3768 KiB
016.txt TLE 2205 ms 3988 KiB
017.txt AC 667 ms 3780 KiB
018.txt AC 1089 ms 3980 KiB
019.txt TLE 2205 ms 3120 KiB
020.txt AC 267 ms 4828 KiB
021.txt AC 266 ms 4816 KiB
022.txt TLE 2205 ms 4008 KiB
023.txt TLE 2205 ms 4084 KiB
024.txt TLE 2205 ms 4132 KiB
025.txt TLE 2205 ms 4132 KiB
example0.txt AC 5 ms 3176 KiB
example1.txt AC 2 ms 2984 KiB