Submission #385031

#TimeUsernameProblemLanguageResultExecution timeMemory
385031zoooma13Money (IZhO17_money)C++14
45 / 100
1574 ms9300 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); vector <int> a(n); vector <pair<int ,int>> sa; for(int&i : a){ scanf("%d",&i); sa.push_back({i ,sa.size()}); } sort(sa.begin() ,sa.end()); for(int j=0,i=0; i<n; i++){ j += (i && sa[i].first != sa[i-1].first); a[sa[i].second] = j; } //for(int&i : a) cout << i << ' '; cout << endl; int ans = 1 ,st = 0; for(int i=1; i<n; i++){ if(a[i] < a[i-1]){ st = i; ans++; continue; } bool bad = false; for(int j=0; j<st; j++) bad |= (a[st] < a[j] && a[j] < a[i]); if(bad){ ans++; st = i; } } printf("%d\n",ans); }

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
money.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         scanf("%d",&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...