# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
747450 | 2023-05-24T07:54:15 Z | vjudge1 | Kralj (COCI16_kralj) | C++17 | 827 ms | 107584 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 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()){ vs[i] = 1; ans++; idk.erase(f); } } for(int i = 1; i <= starting_point; i++){ if(i == starting_point){ if(vs[i]) continue; } 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); } } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 526 ms | 77236 KB | Output is correct |
2 | Correct | 632 ms | 92360 KB | Output is correct |
3 | Correct | 827 ms | 104928 KB | Output is correct |
4 | Correct | 744 ms | 107584 KB | Output is correct |
5 | Incorrect | 358 ms | 63052 KB | Output isn't correct |
6 | Incorrect | 521 ms | 83756 KB | Output isn't correct |
7 | Incorrect | 336 ms | 66700 KB | Output isn't correct |
8 | Incorrect | 269 ms | 65524 KB | Output isn't correct |
9 | Incorrect | 332 ms | 67596 KB | Output isn't correct |
10 | Incorrect | 278 ms | 65032 KB | Output isn't correct |