Submission #747517

#TimeUsernameProblemLanguageResultExecution timeMemory
747517vjudge1Kralj (COCI16_kralj)C++17
140 / 140
1061 ms99028 KiB
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <fstream> #define endl '\n' #define int long long #define mod 998244353; using namespace std; int a[2000001],p[2000001],v[2000001]; int freq[2000001],pre[2000001],suf[2000001]; vector<int>store[2000001]; int vs[2000001],mn[2000001]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, ans = 0; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) cin >> p[i]; for(int i = 1; i <= n; i++) { cin >> v[i]; store[a[i]].push_back(v[i]); } for(int i = 1; i <= n; i++) freq[a[i]]++; int starting_point = 0; set<int>o; for(int i = 1; i <= n; i++) o.insert(i); int lst = 0; for(int i = 1; i <= n; i++){ auto x = o.lower_bound(a[i]); if(x != o.end()){ lst = *x; o.erase(x); }else{ lst = *o.begin(); o.erase(o.begin()); } } lst++; if(lst > n) lst = 1; starting_point = lst; multiset<int>idk; for(int i = starting_point; i <= n; i++){ int j = 0; while(j < store[i].size()){ idk.insert(store[i][j]); j++; } auto f = idk.lower_bound(p[i]); if(f != idk.end()){ ans++; idk.erase(f); }else{ idk.erase(*idk.begin()); } } for(int i = 1; i <= starting_point; i++){ if(i == starting_point){ if(vs[i]) continue; }else{ int j = 0; while(j < store[i].size()){ idk.insert(store[i][j]); j++; } } auto f = idk.lower_bound(p[i]); if(f != idk.end()){ ans++; idk.erase(f); }else{ idk.erase(*idk.begin()); } } cout << ans; return 0; } /* 5 6 30 4 1 0 5 0 2 2 2 3 4 3 4 1 2 4 3 0 3 1 1 1 1 1 1 */

Compilation message (stderr)

kralj.cpp: In function 'int main()':
kralj.cpp:132:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  132 |         while(j < store[i].size()){
      |               ~~^~~~~~~~~~~~~~~~~
kralj.cpp:150:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  150 |             while(j < store[i].size()){
      |                   ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...