| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1301698 | maomao | Global Warming (NOI13_gw) | C++20 | 171 ms | 12616 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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 )
{
ll ans = 0, cnt=0;
vector<pii> v;
rep(i,0,size-1) v.pb({H[i], i});
sort(v.begin(), v.end(), greater<>());
vector<bool> active(size, 0);
rep(i,0,size-1) {
int id = v[i].se;
active[id]=1;
bool l=(id>0&&active[id-1]);
bool r=(id<size-1 && active[id+1]);
if(l && r) cnt--;
else if(!l && !r) cnt++;
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 );
}
Compilation message (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... | ||||
