답안 #149277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149277 2019-09-01T06:07:15 Z Dopatii(#3751, bogdan10bos, Gioto, Bodo171) 십자가 놓기 (FXCUP4_cross) C++17
8 / 100
593 ms 24684 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;

struct elem{
    int x, y;

    bool operator < (const elem &aux)const{
        if(x != aux.x) return x > aux.x;
        return y < aux.y;
    }

};

elem a[200005];

int n;
int aib[200005];
map <int, int> f, f2;

void u(int x, int v){
    for(int i = x; i <= n ; i = i + (i & (-i))) aib[i] += v;
}

int q(int x){
    int ans = 0;
    for(int i = x; i >= 1 ; i = i - (i & (-i))) ans += aib[i];
    return ans;
}

int kth(int k){
    int st = 1, dr = n;
    while(st <= dr){
        int mij = (st + dr) / 2;
        if(q(n) - q(mij - 1) < k) dr = mij - 1;
        else st = mij + 1;
    }

    return f2[dr];
}


long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	int N = I.size();
    n = N;

	for(int i = 1; i <= N ; ++i){
        a[i] = {I[i - 1], O[i - 1]};
	}

	sort(a + 1, a + N + 1);

    for(int i = 1; i <= N ; ++i) f[a[i].y] = i, f2[i] = a[i].y;

    for(int i = 1; i < K ; ++i) u(f[a[i].y], 1);

    long long Sol = 0;
    for(int i = K; i <= N ; ++i){
        u(f[a[i].y], 1);

        int X = a[i].x;
        int Y = kth(K);

        Sol = max(Sol, 2LL * X * Y - 1LL * X * X);
    }

	return Sol;
}










# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 8 ms 512 KB Output is correct
5 Correct 26 ms 1920 KB Output is correct
6 Correct 592 ms 24676 KB Output is correct
7 Correct 593 ms 24424 KB Output is correct
8 Correct 593 ms 24684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 8 ms 512 KB Output is correct
5 Correct 26 ms 1920 KB Output is correct
6 Correct 592 ms 24676 KB Output is correct
7 Correct 593 ms 24424 KB Output is correct
8 Correct 593 ms 24684 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 8 ms 512 KB Output is correct
5 Correct 26 ms 1920 KB Output is correct
6 Correct 592 ms 24676 KB Output is correct
7 Correct 593 ms 24424 KB Output is correct
8 Correct 593 ms 24684 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
10 Halted 0 ms 0 KB -