Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 3 KBi |
#2 |
Correcto
|
0.005 s | 12 KBi |
#3 |
Correcto
|
0.005 s | 4 KBi |
#4 |
Error interno
No such file or directory @ rb_sysopen - /box/main.cpp |
||
#5 |
Correcto
|
0.004 s | 9 KBi |
#6 |
Correcto
|
0.169 s | 6 KBi |
#7 |
Correcto
|
0.133 s | 6 KBi |
#8 |
Error interno
No such file or directory @ rb_sysopen - /box/main.cpp |
||
#9 |
Correcto
|
0.271 s | 8 KBi |
#10 |
Error interno
No such file or directory @ rb_sysopen - /box/main.cpp |
#include <algorithm> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<ll> vl; #define sz(x) ((int)x.size()) #define MPI 3.14159265358979323846 #define pb push_back #define all(x) x.begin(), x.end() void __print(int x) {cerr << x;} void __print(ll x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef Debug #define dbg(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define dbg(x...) #endif void solve(){ stack<int>s; int n; cin>>n; vector<int>a(n); vector<int>ans(n, -1); for(int i=0; i<n; i++){ cin>>a[i]; } for(int i=0; i<n; i++){ while(s.size() && a[s.top()] < a[i]){ ans[s.top()] = a[i]; s.pop(); } s.push(i); } for(auto i : ans){ cout<<i<<" "; } cout<<endl; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T=1; cin>> T; int i=1; while(T--){ cout<<"Case #"<<i<<": "; solve(); i++; } return 0; }