Submission #37367

#TimeUsernameProblemLanguageResultExecution timeMemory
37367HardNutMoney (IZhO17_money)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; typedef long long ll; int n, a[N], ans; set<pair<int, int>> st; int main() { // freopen("money.in", "r", stdin); // freopen("money.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { st.insert({a[i], i}); auto id = st.find({a[i], i}); if (id == st.begin()) { ans++; continue; } id--; if ((*id).second == i - 1) { continue; } id = st.upper_bound({a[i], 0}); if (id == st.begin()) { ans++; continue; }#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; typedef long long ll; int n, a[N], ans, lst; set<pair<int, int>> st; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { st.insert({a[i], i}); if (lst == a[i]) continue; lst = a[i]; auto id = st.find({a[i], i}); if (id == st.begin()) { ans++; continue; } id--; if ((*id).second == i - 1) { continue; } id = st.lower_bound({a[i], -1}); if (id == st.begin()) { ans++; continue; } id--; if ((*id).second == i - 1) { st.erase({a[i], i}); continue; } ans++; } cout << ans; } /** 6 1 5 2 5 5 6 **/ id--; if ((*id).second == i - 1) { continue; } ans++; } cout << ans; }

Compilation message (stderr)

money.cpp:36:10: error: stray '#' in program
         }#include <bits/stdc++.h>
          ^
money.cpp: In function 'int main()':
money.cpp:36:11: error: 'include' was not declared in this scope
         }#include <bits/stdc++.h>
           ^
money.cpp:36:20: error: 'bits' was not declared in this scope
         }#include <bits/stdc++.h>
                    ^
money.cpp:36:25: error: 'stdc' was not declared in this scope
         }#include <bits/stdc++.h>
                         ^
money.cpp:38:1: error: expected primary-expression before 'using'
 using namespace std;
 ^
money.cpp:47:12: error: a function-definition is not allowed here before '{' token
 int main() {
            ^
money.cpp:94:1: error: expected '}' at end of input
 }
 ^
money.cpp:44:5: warning: unused variable 'n' [-Wunused-variable]
 int n, a[N], ans, lst;
     ^
money.cpp:44:8: warning: unused variable 'a' [-Wunused-variable]
 int n, a[N], ans, lst;
        ^
money.cpp:44:14: warning: unused variable 'ans' [-Wunused-variable]
 int n, a[N], ans, lst;
              ^
money.cpp:44:19: warning: unused variable 'lst' [-Wunused-variable]
 int n, a[N], ans, lst;
                   ^
money.cpp:94:1: error: expected '}' at end of input
 }
 ^