Submission #924655

#TimeUsernameProblemLanguageResultExecution timeMemory
924655sleepntsheepGlobal Warming (NOI13_gw)C++17
23 / 40
195 ms20940 KiB
#include <bits/stdc++.h> using namespace std; #define N 1000005 int n, f[N], z; pair<int, int> a[N]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i].first), a[i].second = i + 2; sort(a, a+n); for (int distinct = 0, i = n; i--;) { int x = a[i].second; if (!f[x-1] && !f[x+1]) distinct++; else if (f[x-1] ^ f[x+1]) ; else distinct--; f[x] = 1; z = max(z, distinct); } printf("%d\n", z); return 0; }

Compilation message (stderr)

gw.cpp: In function 'int main()':
gw.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
gw.cpp:12:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (int i = 0; i < n; i++) scanf("%d", &a[i].first), a[i].second = i + 2;
      |                                 ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...