Submission #917631

#TimeUsernameProblemLanguageResultExecution timeMemory
917631enviflyStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
204 ms14692 KiB
#include <bits/stdc++.h>

#ifndef LOCAL
#define debug(...) 0
#else
#include "C:\programmingfunnyxd\debug.cpp"
#endif

using namespace std;
const int MOD = 1e9 + 7;
using ll = long long;
#define all(x) x.begin(), x.end()

void solve(){
	int n; cin >> n;
	map<int, int> last;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		last[a[i]] = i;
	}
	// the biggest segment reigns supreme
	for(int i = 0; i < n; i++){
		for(int j = i; j <= last[a[i]]; j++){
			cout << a[i] << "\n";
		}
		i = last[a[i]];
	}
	
}

int main(){
	cin.tie(0) -> sync_with_stdio(0);
	int T = 1;
	// cin >> T;
	while(T--) solve();
}

/*   /\_/\
*   (= ._.)
*   / >  \>
*/

Compilation message (stderr)

Main.cpp:39:9: warning: "/*" within comment [-Wcomment]
   39 | /*   /\_/\
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...