답안 #225797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225797 2020-04-21T17:11:43 Z osaaateiasavtnl Kralj (COCI16_kralj) C++14
0 / 140
2000 ms 67408 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
 
const int N = 5e5 + 7;
int a[N], p1[N], p2[N];
set <int> add[N];

bool comp(int i, int j) {
    return p1[i] > p1[j];
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }   
    for (int i = 1; i <= n; ++i)
        cin >> p1[i];
    for (int i = 1; i <= n; ++i) {
        cin >> p2[i];
        add[a[i]].insert(p2[i]);
    }
    vector <int> per;
    for (int i = 1; i <= n; ++i)
        per.app(i);
    sort(all(per), comp);
    int ans = 0;         
    for (int i : per) {
        int j = i;
        while (add[j].empty()) {
            --j;
            if (j == 0)
                j = n;
        }   
        auto t = add[j].upper_bound(p1[i]);
        if (t != add[j].end()) {
            ++ans;
            add[j].erase(t);
        }   
        else {
            add[j].erase(add[j].begin());
        }   
    }   
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2088 ms 60980 KB Time limit exceeded
2 Execution timed out 2077 ms 61184 KB Time limit exceeded
3 Execution timed out 2090 ms 66416 KB Time limit exceeded
4 Execution timed out 2087 ms 67408 KB Time limit exceeded
5 Execution timed out 2083 ms 62812 KB Time limit exceeded
6 Incorrect 1656 ms 62724 KB Output isn't correct
7 Incorrect 1740 ms 64144 KB Output isn't correct
8 Incorrect 1054 ms 60844 KB Output isn't correct
9 Incorrect 1555 ms 66104 KB Output isn't correct
10 Execution timed out 2091 ms 66048 KB Time limit exceeded