제출 #1323246

#제출 시각아이디문제언어결과실행 시간메모리
1323246hyyhStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
248 ms25064 KiB
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <cstring>
#include <iomanip>
#include <set>
#include <bitset>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using piii = tuple<int,int,int>;
#define endl '\n'

int main(){
    int n;cin >> n;
    map<int,vector<int>> mp;
    vector<int> vc;
    for(int i{};i < n;i++){
        int g;cin >> g;
        vc.emplace_back(g);
        if(!mp.count(g)) mp[g] = {};
        mp[g].emplace_back(i);
    }
    for(int i{};i < n;i++){
        auto &vect = mp[vc[i]];
        auto it = upper_bound(vect.begin(),vect.end(),i);
        if(it == vect.end()) cout << vc[i] << endl;
        else{
            int length = *it-i;
            //cout << length << " ";
            for(int j{};j < length;j++){
                cout << vc[i] << endl;
            }
            i += length-1;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...