#include<bits/stdc++.h>
#include "wall.h"
#define ll long long
#define f first
#define s second
using namespace std;
const int maxn=2e6+5;
int N,Q;
vector<pair<int,int>> sta[maxn];
int resavaj(vector<pair<int,int>> V){
int maxa=0,minr=1e9,v1=0,v2=0;
for(int i=0;i<V.size();i++)
if(V[i].f==1)
v2=max(v2,V[i].s);
for(int i=0;i<V.size();i++){
if(V[i].f==1)
maxa=max(maxa,V[i].s);
else{
if(V[i].s<=maxa)
v2=min(v2,V[i].s);
}
}
for(int i=V.size()-1;i>=0;i--){
if(V[i].f==2)
minr=min(minr,V[i].s);
else
if(V[i].s<=minr)
v1=max(v1,V[i].s);
}
// cout<<v1<<" "<<v2<<endl;
return max(v1,v2);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
N=n;
Q=k;
for(int i=0;i<Q;i++){
for(int j=left[i];j<=right[i];j++)
sta[j].push_back({op[i],height[i]});
}
for(int i=0;i<N;i++)
finalHeight[i]=resavaj(sta[i]);
}
Compilation message
wall.cpp: In function 'int resavaj(std::vector<std::pair<int, int> >)':
wall.cpp:12:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for(int i=0;i<V.size();i++)
| ~^~~~~~~~~
wall.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int i=0;i<V.size();i++){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
47332 KB |
Output is correct |
2 |
Incorrect |
20 ms |
47452 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
47192 KB |
Output is correct |
2 |
Correct |
105 ms |
63104 KB |
Output is correct |
3 |
Runtime error |
314 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
47196 KB |
Output is correct |
2 |
Incorrect |
11 ms |
47452 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
47404 KB |
Output is correct |
2 |
Incorrect |
15 ms |
47452 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |