Submission #966538

#TimeUsernameProblemLanguageResultExecution timeMemory
966538yellowtoadMoney (IZhO17_money)C++17
0 / 100
1 ms348 KiB
#include <iostream> #include <set> #include <vector> using namespace std; int n, a[1000010], cnt; multiset<int> bst; multiset<int>::iterator iter; vector<int> tmp; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { if (a[i-1] > a[i]) { cnt++; for (int j = 0; j < tmp.size(); j++) bst.insert(tmp[j]); tmp.clear(); } else { iter = bst.lower_bound(a[i-1]); if ((iter != bst.end()) && (*iter < a[i])) { cnt++; for (int j = 0; j < tmp.size(); j++) bst.insert(tmp[j]); tmp.clear(); } } tmp.push_back(a[i]); } cout << cnt+1 << endl; }

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |    for (int j = 0; j < tmp.size(); j++) bst.insert(tmp[j]);
      |                    ~~^~~~~~~~~~~~
money.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int j = 0; j < tmp.size(); j++) bst.insert(tmp[j]);
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...