Submission #1149074

#TimeUsernameProblemLanguageResultExecution timeMemory
1149074blackslexStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
245 ms12468 KiB
#include<bits/stdc++.h>

using namespace std;

int n;

int main() {
    scanf("%d", &n);
    vector<int> a(n);
    map<int, int> nxt;
    map<int, vector<int>> mp;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        nxt[a[i]] = i;
    }
    int mn = -1;
    for (int i = 0; i < n; i++) {
        if (mn >= i) continue;
        for (int j = i; j <= nxt[a[i]]; j++) a[j] = a[i];
        mn = nxt[a[i]];
    }
    for (auto &e: a) printf("%d\n", e);
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...