| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1301705 | maomao | Global Warming (NOI13_gw) | C++20 | 177 ms | 12620 KiB |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
int GW ( int size, int *H )
{
int ans = 0, cnt=0;
vector<pii> v;
rep(i,0,size-1) v.pb({H[i], i});
sort(v.begin(), v.end());
vector<bool> active(size, 0);
while(v.size()) {
int h = v.back().fi;
while(v.size() && v.back().fi==h) {
active[v.back().se] = 1;
bool l = (v.back().se>0 && active[v.back().se - 1]),
r = (v.back().se<size-1 && active[v.back().se + 1]);
if(l&&r) cnt--;
if(!l && !r) cnt++;
v.pop_back();
}
ans = max(ans, cnt);
}
return ans;
}
int main()
{
int size;
//int *H;
int i;
int NumberOfIslands;
/*------------------------*/
/* R e a d i n p u t */
/*------------------------*/
scanf ("%d", &size );
//H = malloc ( size* sizeof(int) );
int H[size];
for (i=0; i<size; i++)
{ scanf ("%d", &H[i] ); }
NumberOfIslands = GW ( size, H );
printf ( "%d\n", NumberOfIslands );
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
