# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747459 | 2023-05-24T08:02:12 Z | vjudge1 | Kralj (COCI16_kralj) | C++17 | 534 ms | 94288 KB |
#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]; 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]]++; for(int i = 1; i <= n; i++) pre[i] += pre[i - 1] + freq[i]; for(int i = n; i >= 1; i--) suf[i] += suf[i + 1] + freq[i]; int starting_point = 0; for(int i = 1; i <= n; i++){ if(pre[i] + suf[i + 1] <= n - i + 1) starting_point = i; } 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 534 ms | 84972 KB | Output is correct |
2 | Correct | 343 ms | 84144 KB | Output is correct |
3 | Correct | 446 ms | 93168 KB | Output is correct |
4 | Correct | 431 ms | 94288 KB | Output is correct |
5 | Incorrect | 290 ms | 74828 KB | Output isn't correct |
6 | Incorrect | 271 ms | 75096 KB | Output isn't correct |
7 | Incorrect | 329 ms | 77532 KB | Output isn't correct |
8 | Incorrect | 292 ms | 74952 KB | Output isn't correct |
9 | Incorrect | 352 ms | 79192 KB | Output isn't correct |
10 | Incorrect | 314 ms | 77608 KB | Output isn't correct |