Submission #386213

#TimeUsernameProblemLanguageResultExecution timeMemory
386213kinglineMoney (IZhO17_money)C++17
100 / 100
1271 ms62092 KiB
/*#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("avx,avx2,fma")*/ #include <iostream> #include <stdio.h> #include <algorithm> #include <cstdio> #include <cstdlib> #include <iomanip> #include <cmath> #include <vector> #include <string> #include <stack> #include <map> #include <set> #include <queue> #define pb push_back #define F first #define mp make_pair #define S second #define pii pair <int, int > #define pll pair <long long, long long > #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define all(data) data.begin() , data.end() #define endl '\n' #define bo cout << "OK" << endl; #define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout); //freopen("nenokku_easy.in", "r", stdin); //freopen("nenokku_easy.out", "w", stdout); #define int long long using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; const ll N = 1e6 + 1; const ll mod = 1e9 + 7; const ll INF = 1e10; const ll M = (1 << 17) + 1; const ll LL = 1; const ll p = 31; bool ok; int gcd (int a, int b) { if (b == 0) return a; else return gcd (b, a % b); } ll bp (int a, int b) { if(b == 0) return 1; else if(b % 2) return ((bp(a, b - 1) % mod) * a) % mod; else { int c = bp(a, b / 2) % mod; return (c * c) % mod; } } ll sum(int x) { int res = 0; while(x) { res += x % 10; x /= 10; } return res; } ll q, n, m, k, a[N], pref[N], b[N]; string s, s1, s2; void solve() { cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; } multiset < int > st; st.insert(1e7); st.insert(-1); int ans = 0; a[0] = -1; a[n + 1] = 1e7; for(int i = 1; i <= n; i++) { multiset < int >::iterator itt = st.upper_bound(a[i]); st.insert(a[i]); //cout << a[i] << " "; while(a[i] <= a[i + 1] && a[i + 1] <= *itt && i + 1 <= n) { ++i; st.insert(a[i]); //cout << a[i] << " "; } //cout << endl; ++ans; } cout << ans; } main() { //file("B"); ios; q = 1; //cin >> q; while(q--) { solve(); } }

Compilation message (stderr)

money.cpp:99:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   99 | main()
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...