# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
566756 | Redhood | Kralj (COCI16_kralj) | C++14 | 482 ms | 86324 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef long double ld;
const int N = (int)1e5 + 10;
vector < int > atcur[N];
int main()
{
ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
int n;
cin >> n;
vector < int > a(n);
vector < int > c(n);
for(auto &i : a)
cin >> i, --i, c[i]++;
for(int i = 0; i < n; ++i){
atcur[a[i]].pb(i);
}
vector < int > p(n) , v(n);
for(auto &i : p)cin >> i;
for(auto &i : v)cin >> i;
vector < int > pref(n);
pref[0] = c[0];
for(int i = 1; i < n; ++i){
pref[i] = pref[i - 1] + c[i];
}
/// damn
for(int i = 0; i < n; ++i){
pref[i] -= i;
}
int psmn = min_element(all(pref)) - pref.begin();
/// okay
int x = psmn + 1;
if(x == n)
x = 0;
int ans = 0;
set < int > st;
for(int it=0;it<n;++it){
for(auto &u : atcur[x]){
st.insert(v[u]);
}
auto itt = st.lower_bound(p[x]);
if(itt != st.end()){
ans++;
st.erase(itt);
}
x++;
if(x == n)
x = 0;
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |