Submission #425444

# Submission time Handle Problem Language Result Execution time Memory
425444 2021-06-13T03:57:36 Z errorgorn Global Warming (NOI13_gw) C++17
40 / 40
354 ms 18604 KB
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int,int> ii;
vector<ii> v;
int n,t,islands,max_islands,pp=1;
bool arr[1000005];
int main(){
  scanf("%d",&n);
  for (int x=1;x<=n;x++){
    scanf("%d",&t);
    v.push_back(ii (-t,x));
  }
  sort(v.begin(),v.end());
  for (vector<ii>::iterator it=v.begin();it!=v.end();it++){
    if ((*it).first!=pp){
        pp=(*it).first;
        max_islands=max(islands,max_islands);
    }
    t=(*it).second;
    if (!(arr[t-1] || arr[t+1])){
      islands++;
    }
    else if (arr[t-1] && arr[t+1]){
      islands--;
    }
    arr[t]=true;
  }
  printf("%d\n",max(max_islands,islands));
}

Compilation message

gw.cpp: In function 'int main()':
gw.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
gw.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1604 KB Output is correct
2 Correct 24 ms 1640 KB Output is correct
3 Correct 29 ms 1704 KB Output is correct
4 Correct 24 ms 1692 KB Output is correct
5 Correct 24 ms 1604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2156 KB Output is correct
2 Correct 20 ms 1988 KB Output is correct
3 Correct 31 ms 2116 KB Output is correct
4 Correct 29 ms 2128 KB Output is correct
5 Correct 27 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 286 ms 18484 KB Output is correct
2 Correct 354 ms 18460 KB Output is correct
3 Correct 307 ms 18604 KB Output is correct
4 Correct 281 ms 18500 KB Output is correct
5 Correct 269 ms 17892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 293 ms 17824 KB Output is correct
2 Correct 283 ms 17820 KB Output is correct
3 Correct 293 ms 17820 KB Output is correct
4 Correct 249 ms 11968 KB Output is correct
5 Correct 249 ms 11928 KB Output is correct