답안 #1000160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000160 2024-06-16T18:25:39 Z flappybird Naan (JOI19_naan) C++17
0 / 100
1 ms 2392 KB
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 2020
#define MAXQ 101010
#define INF 1000000000000000000
#define MOD 998244353
#define bb ' '
#define ln '\n'
#define Ln '\n'
int V[MAX][MAX];
ll sum[MAX][MAX];
int N, L;
bool operator<(pll p1, pll p2) { return p1.first * p2.second < p2.first * p1.second; }
bool operator<=(pll p1, ll p2) { return p1.first <= p2 * p1.second; }
pll get(int ind, int v) {
	int l, r;
	l = 0;
	r = L;
	while (r - l > 1) {
		int m = l + r >> 1;
		if (pll(v * sum[ind][L], N) <= sum[ind][m]) r = m;
		else l = m;
	}
	r--;
	return pll(V[ind][r + 1] * N * r + sum[ind][L] * v - sum[ind][r] * N, V[ind][r + 1] * N);
}
pll ans[MAX];
int P[MAX];
int vis[MAX];
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> N >> L;
	int i, j;
	for (i = 1; i <= N; i++) for (j = 1; j <= L; j++) cin >> V[i][j], sum[i][j] = sum[i][j - 1] + V[i][j];
	for (i = 1; i <= N; i++) {
		pll mn = pll(L + 1, 1);
		int mv = 0;
		for (j = 1; j <= N; j++) {
			if (vis[j]) continue;
			pll v = get(j, i);
			if (mn > v) mn = v, mv = j;
		}
		P[i] = mv;
		vis[mv] = 1;
		ans[i] = mn;
		ll g = gcd(ans[i].first, ans[i].second);
		ans[i].first /= g;
		ans[i].second /= g;
		if (i < N) cout << ans[i].first << bb << ans[i].second << ln;
	}
	for (i = 1; i <= N; i++) cout << P[i] << bb;
}

Compilation message

naan.cpp: In function 'pll get(int, int)':
naan.cpp:28:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |   int m = l + r >> 1;
      |           ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB X_i is not increasing
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB X_i is not increasing
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB X_i is not increasing
2 Halted 0 ms 0 KB -