Submission #229870

#TimeUsernameProblemLanguageResultExecution timeMemory
229870pedroslreyMoney (IZhO17_money)C++14
100 / 100
1160 ms62172 KiB
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using lli = long long int; #define debug(args...) fprintf(stderr, args) #define pb push_back #define fi first #define se second #define all(xs) xs.begin(), xs.end() const int INF = 1e9; vector<int> xs; vector<int> ys; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); xs.pb(x); } ys.push_back(xs[0]); for (int i = 1; i < n; ++i) if (xs[i] != xs[i-1]) ys.push_back(xs[i]); int m = (int)ys.size(); set<int> s; s.insert(INF); int total = 1; int k = 0; for (int i = 0; i < m-1; ++i) { if ((ys[i] > ys[i+1]) || (ys[i] < ys[i+1] && *s.lower_bound(ys[i]-k+1) < ys[i+1])){ k = 0; ++total; } else k = 1; s.insert(ys[i]); } printf("%d\n", total); }

Compilation message (stderr)

money.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
money.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
money.cpp: In function 'int main()':
money.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
money.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...