Submission #386257

#TimeUsernameProblemLanguageResultExecution timeMemory
386257patrikpavic2Money (IZhO17_money)C++17
0 / 100
1 ms384 KiB
#include <cstdio> #include <cstring> #include <vector> #include <set> #include <algorithm> #define X first #define Y second #define PB push_back using namespace std; const int N = 1e6 + 500; int A[N], n, prv[N], nxt[N], sol; multiset < int > S; int main(){ scanf("%d", &n); for(int i = 0;i < n;i++){ scanf("%d", A + i); S.insert(A[i]); } for(int i = n - 1;i >= 0;i--){ S.erase(S.lower_bound(A[i])); while(i > 0 && A[i - 1] == A[i]){ i--; S.erase(S.lower_bound(A[i])); } if(i > 0 && A[i] > *S.begin() && A[i - 1] == *(--S.lower_bound(A[i]))){ i--; S.erase(S.lower_bound(A[i])); } while(i > 0 && A[i - 1] == *(--S.upper_bound(A[i]))){ i--; S.erase(S.lower_bound(A[i])); } sol++; } printf("%d\n", sol); }

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
money.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |   scanf("%d", A + i);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...