답안 #532011

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532011 2022-03-02T03:31:08 Z Haruto810198 Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
34 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())

#define vi vector<int>
#define pii pair<int, int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF = INT_MAX;
const int LNF = INF*INF;
const int MOD = 1000000007;
const int mod = 998244353;
const double eps = 1e-12;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

const int MAX = 510;

struct State{
	double A, B;	
};

int n, k;
State state[MAX];
double res;

bool cmp_by_A(State x, State y){
	return (x.A < y.A);
}

bool cmp_by_B(State x, State y){
	return (x.B < y.B);
}

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	FOR(i, 1, n, 1){
		cin>>state[i].A>>state[i].B;
		if(state[i].B == -1) state[i].B = INF;
	}
	
	res = INF;
	// enum. n. of collaborators
	FOR(i, 0, k, 1){
		// i collaborators

		sort(state+1, state+n+1, cmp_by_B);
		sort(state+i+1, state+n+1, cmp_by_A);
		
		double sum = 0;
		double col = 1;
		FOR(j, 1, i, 1){
			sum += state[j].B / col;
			col += 1;
		}

		FOR(j, i+1, k, 1){
			sum += state[j].A / col;
		}

		res = min(res, sum);
		//cerr<<"i = "<<i<<" : sum = "<<sum<<endl;
	}

	cout<<fixed<<setprecision(12)<<res<<'\n';
	
	return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 5 ms 332 KB Output is correct
6 Correct 7 ms 320 KB Output is correct
7 Correct 13 ms 340 KB Output is correct
8 Correct 17 ms 340 KB Output is correct
9 Correct 20 ms 332 KB Output is correct
10 Correct 15 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 5 ms 332 KB Output is correct
6 Correct 7 ms 320 KB Output is correct
7 Correct 13 ms 340 KB Output is correct
8 Correct 17 ms 340 KB Output is correct
9 Correct 20 ms 332 KB Output is correct
10 Correct 15 ms 332 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 8 ms 332 KB Output is correct
13 Correct 12 ms 344 KB Output is correct
14 Correct 15 ms 344 KB Output is correct
15 Correct 16 ms 344 KB Output is correct
16 Correct 24 ms 340 KB Output is correct
17 Correct 18 ms 332 KB Output is correct
18 Correct 20 ms 336 KB Output is correct
19 Correct 26 ms 332 KB Output is correct
20 Correct 23 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 5 ms 332 KB Output is correct
6 Correct 7 ms 320 KB Output is correct
7 Correct 13 ms 340 KB Output is correct
8 Correct 17 ms 340 KB Output is correct
9 Correct 20 ms 332 KB Output is correct
10 Correct 15 ms 332 KB Output is correct
11 Correct 0 ms 316 KB Output is correct
12 Correct 8 ms 332 KB Output is correct
13 Correct 12 ms 344 KB Output is correct
14 Correct 15 ms 344 KB Output is correct
15 Correct 16 ms 344 KB Output is correct
16 Correct 24 ms 340 KB Output is correct
17 Correct 18 ms 332 KB Output is correct
18 Correct 20 ms 336 KB Output is correct
19 Correct 26 ms 332 KB Output is correct
20 Correct 23 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 316 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Incorrect 1 ms 204 KB Output isn't correct
30 Halted 0 ms 0 KB -