Submission #711235

# Submission time Handle Problem Language Result Execution time Memory
711235 2023-03-16T10:51:49 Z youngyojun Naan (JOI19_naan) C++17
0 / 100
2 ms 372 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define allv(V) (V).begin(),(V).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
ll operator * (pll a, pll b) { return a.fi*b.se - a.se*b.fi; }

pll B[2005][2005];
ll A[2005];

int C[2005];

int N, L;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> N >> L;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < L; j++) {
			ll x; cin >> x;
			A[j+1] = A[j] + x;
		}
		ll S = A[L];
		int k = 1, n = 0;
		while(k < N) {
			while(A[n+1]*N <= S*k) n++;
			ll u = S*k - A[n]*N, d = (A[n+1]-A[n])*N;
			B[i][k++] = {u + d*n, d};
		}
	}

	vector<int> V(N); iota(allv(V), 0);
	for(int k = 1; k < N; k++)
		swap(V[k-1], *min_element(k-1+allv(V), [&](int a, int b) {
			return 0 < B[a][k] * B[b][k];
		}));
	
	for(int k = 1; k < N; k++) {
		pll p = B[V[k-1]][k];
		cout << p.fi << ' ' << p.se << '\n';
	}
	for(int v : V) cout << v+1 << ' ';
	cout << '\n';

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Not a fair distribution.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 372 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Incorrect 1 ms 340 KB Not a fair distribution.
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Not a fair distribution.
2 Halted 0 ms 0 KB -