제출 #465020

#제출 시각아이디문제언어결과실행 시간메모리
465020TeaTimeMoney (IZhO17_money)C++17
45 / 100
1590 ms102228 KiB
//#pragma GCC optimize("O3") //#pragma GCC target("avx2") #include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> #include <set> #include <queue> #include <unordered_map> using namespace std; #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); typedef long long ll; typedef long double ld; #define int ll const ll SZ = 1e6 + 10, INF = 1e9; ll n, m, q; vector<ll> vec; signed main() { fastInp; cin >> n; vec.resize(n); ll ans = 0; for (auto& c : vec) cin >> c; multiset<ll> er; map<ll, ll> cnt_all; for (int i = 0; i < n; i++) { er.insert(vec[i]); cnt_all[vec[i]]++; } er.insert(INF); if (er.size() != n + 1) return 1; map<ll, ll> cnt; while (vec.size()) { ans++; ll cur = vec.back(); vector<ll> ltr; ltr.push_back(cur); vec.pop_back(); ll ths = 1; cnt[cur]++; while (vec.size() > 0) { if (vec.back() == cur) { ltr.push_back(vec.back()); cur = vec.back(); cnt[cur]++; vec.pop_back(); continue; } ll q = (*(er.lower_bound(vec.back() + 1))); if (vec.size() > 0 && q == cur && (ths == 1 || cnt[cur] == cnt_all[cur])) { ltr.push_back(vec.back()); cur = vec.back(); cnt[cur]++; vec.pop_back(); ths++; } else { break; } } for (auto c : ltr) er.erase(er.find(c)); } if (er.size() != 1) return 1; cout << ans; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

money.cpp: In function 'int main()':
money.cpp:41:19: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   41 |     if (er.size() != n + 1) return 1;
      |         ~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...