Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 38 KBi |
#2 |
Correcto
|
0.005 s | 19 KBi |
#3 |
Correcto
|
0.006 s | 7 KBi |
#4 |
Correcto
|
0.007 s | 52 KBi |
#5 |
Correcto
|
0.004 s | 19 KBi |
#6 |
Correcto
|
0.144 s | 6 KBi |
#7 |
Correcto
|
0.204 s | 6 KBi |
#8 |
Correcto
|
0.13 s | 47 KBi |
#9 |
Correcto
|
0.135 s | 6 KBi |
#10 |
Correcto
|
0.242 s | 8 KBi |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pi; #define F first #define S second #define PB push_back #define MP make_pair #define forn(i,a,b) for(int i=a;i<=b;i++) #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define endl "\n" #define euler 10e-9 int main() { ios::sync_with_stdio(0); cin.tie(0); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); //fflush(stdout); -->forzar salida a sistema operativo cuando se esta usando "\n", enld ya lo incluye int c;cin>>c; for(int i=0;i<c;++i){ int n;cin>>n; int arr[n], answer[n]; for(int j=0;j<n;++j)cin>>arr[j]; stack<int> nums; for(int j=n-1;j>=0;--j){ while(!nums.empty() && arr[j]>=nums.top()){ nums.pop(); }if(!nums.empty())answer[j]=nums.top(); else answer[j]=-1; nums.push(arr[j]); } cout<<"Case #"<<i+1<<": "; for(auto x:answer)cout<<x<<" "; cout<<endl; } return 0; }