답안 #535198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535198 2022-03-09T16:37:33 Z pooyashams Naan (JOI19_naan) C++17
29 / 100
188 ms 86872 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int maxn = 2012;

struct mfint
{
	ll a, b; // a/b
	mfint()
	{
		a = 1;
		b = 1;
	};
	mfint(ll _a, ll _b)
	{
		a = _a;
		b = _b;
	}
	inline bool operator<(const mfint &o) const
	{
		return a*o.b < o.a*b;
	}
};

int vals[maxn][maxn];
int ps[maxn][maxn];
mfint blues[maxn][maxn];
int f;

ll n, L;

inline void prn(mfint a)
{
	cerr << a.a << "/" << a.b << " ";
}

//inline int cmp(int i, int j)
//{
//	return blues[i][f] < blues[j][f];
//}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> L;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < L; j++)
		{
			cin >> vals[i][j];
			ps[i][j+1] = ps[i][j]+vals[i][j];
		}
	}
	for(int i = 0; i < n; i++)
	{
		int p = 0;
		ll s = ps[i][L];
		for(int j = 1; j <= n; j++)
		{
			while( (n*(ps[i][p] + vals[i][p])) < s*j )
				p++;
			blues[i][j-1] = mfint(s*j-n*ps[i][p] + n*vals[i][p]*p, n*vals[i][p]);
			//prn(blues[i][j]);
		}
	}
	vector<int> rem(n);
	iota(rem.begin(), rem.end(), 0);
	vector<int> prm;
	vector<mfint> mfs;
	for(int f = 0; f < n; f++)
	{
		int mnidx = min_element(rem.begin(), rem.end(), [&](int i, int j){ return blues[i][f] < blues[j][f];}) - rem.begin();
		//cerr << rem[mnidx] << endl;
		prm.push_back(rem[mnidx]);
		mfs.push_back(blues[rem[mnidx]][f]);
		rem.erase(rem.begin()+mnidx);
	}
	mfs.pop_back();
	for(mfint m: mfs)
		cout << m.a << " " << m.b << endl;
	for(int x: prm)
		cout << x+1 <<  " ";
	cout << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 63692 KB Output is correct
2 Correct 26 ms 63672 KB Output is correct
3 Correct 26 ms 63688 KB Output is correct
4 Correct 27 ms 63652 KB Output is correct
5 Correct 28 ms 63624 KB Output is correct
6 Correct 28 ms 63632 KB Output is correct
7 Correct 28 ms 63692 KB Output is correct
8 Correct 26 ms 63680 KB Output is correct
9 Correct 27 ms 63596 KB Output is correct
10 Correct 26 ms 63720 KB Output is correct
11 Correct 27 ms 63688 KB Output is correct
12 Correct 29 ms 63684 KB Output is correct
13 Correct 34 ms 63680 KB Output is correct
14 Correct 30 ms 63692 KB Output is correct
15 Correct 28 ms 63712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 63684 KB Output is correct
2 Correct 27 ms 63692 KB Output is correct
3 Correct 28 ms 63692 KB Output is correct
4 Correct 27 ms 63684 KB Output is correct
5 Correct 27 ms 63784 KB Output is correct
6 Correct 28 ms 63708 KB Output is correct
7 Correct 27 ms 63680 KB Output is correct
8 Correct 29 ms 63648 KB Output is correct
9 Correct 27 ms 63820 KB Output is correct
10 Correct 27 ms 63768 KB Output is correct
11 Correct 29 ms 63812 KB Output is correct
12 Correct 26 ms 63588 KB Output is correct
13 Correct 27 ms 63684 KB Output is correct
14 Correct 28 ms 63700 KB Output is correct
15 Correct 29 ms 63692 KB Output is correct
16 Correct 27 ms 63764 KB Output is correct
17 Correct 28 ms 63744 KB Output is correct
18 Correct 29 ms 63692 KB Output is correct
19 Correct 28 ms 63692 KB Output is correct
20 Correct 29 ms 63808 KB Output is correct
21 Correct 29 ms 63812 KB Output is correct
22 Correct 29 ms 63692 KB Output is correct
23 Correct 28 ms 63680 KB Output is correct
24 Correct 28 ms 63692 KB Output is correct
25 Correct 28 ms 63704 KB Output is correct
26 Correct 27 ms 63612 KB Output is correct
27 Correct 28 ms 63728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 63692 KB Output is correct
2 Correct 26 ms 63672 KB Output is correct
3 Correct 26 ms 63688 KB Output is correct
4 Correct 27 ms 63652 KB Output is correct
5 Correct 28 ms 63624 KB Output is correct
6 Correct 28 ms 63632 KB Output is correct
7 Correct 28 ms 63692 KB Output is correct
8 Correct 26 ms 63680 KB Output is correct
9 Correct 27 ms 63596 KB Output is correct
10 Correct 26 ms 63720 KB Output is correct
11 Correct 27 ms 63688 KB Output is correct
12 Correct 29 ms 63684 KB Output is correct
13 Correct 34 ms 63680 KB Output is correct
14 Correct 30 ms 63692 KB Output is correct
15 Correct 28 ms 63712 KB Output is correct
16 Correct 26 ms 63684 KB Output is correct
17 Correct 27 ms 63692 KB Output is correct
18 Correct 28 ms 63692 KB Output is correct
19 Correct 27 ms 63684 KB Output is correct
20 Correct 27 ms 63784 KB Output is correct
21 Correct 28 ms 63708 KB Output is correct
22 Correct 27 ms 63680 KB Output is correct
23 Correct 29 ms 63648 KB Output is correct
24 Correct 27 ms 63820 KB Output is correct
25 Correct 27 ms 63768 KB Output is correct
26 Correct 29 ms 63812 KB Output is correct
27 Correct 26 ms 63588 KB Output is correct
28 Correct 27 ms 63684 KB Output is correct
29 Correct 28 ms 63700 KB Output is correct
30 Correct 29 ms 63692 KB Output is correct
31 Correct 27 ms 63764 KB Output is correct
32 Correct 28 ms 63744 KB Output is correct
33 Correct 29 ms 63692 KB Output is correct
34 Correct 28 ms 63692 KB Output is correct
35 Correct 29 ms 63808 KB Output is correct
36 Correct 29 ms 63812 KB Output is correct
37 Correct 29 ms 63692 KB Output is correct
38 Correct 28 ms 63680 KB Output is correct
39 Correct 28 ms 63692 KB Output is correct
40 Correct 28 ms 63704 KB Output is correct
41 Correct 27 ms 63612 KB Output is correct
42 Correct 28 ms 63728 KB Output is correct
43 Correct 54 ms 71748 KB Output is correct
44 Incorrect 188 ms 86872 KB X_i is not increasing
45 Halted 0 ms 0 KB -