# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
251861 | 2020-07-22T13:02:57 Z | dantoh000 | Naan (JOI19_naan) | C++14 | 2 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> ii; int n,l; ii p[2005][2005]; int vis[2005]; ll a[2005]; int ord[2005]; int main(){ scanf("%d%d",&n,&l); for (int i = 1; i <= n; i++){ ll s = 0; for (int j = 1; j <= l; j++){ scanf("%lld",&a[j]); s += a[j]; } ll o = 0, k = 0; for (int j = 1; j <= n; j++){ while (k < l && (o+a[k])*n < s*j) o += a[k++]; ll A = 1ll*(k-1)*a[k]*n + s*j - o*n; ll B = 1ll*a[k]*n; ll D = __gcd(A,B); p[i][j] = ii(A/D, B/D); } } for (int i = 1; i <= n; i++){ ii best; int cur; int first = 1; for (int j = 1; j <= n; j++){ if (vis[j] == 0){ if (first || best.first*p[i][j].second > best.second*p[i][j].first){ first = 0; best = p[i][j]; cur= j; } } } ord[i] = cur; vis[cur] = 1; if (i != n) printf("%lld %lld\n",best.first,best.second); } for (int i = 1; i <= n; i++){ printf("%d ",ord[i]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Not a fair distribution. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Incorrect | 1 ms | 384 KB | Not a fair distribution. |
24 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Not a fair distribution. |
2 | Halted | 0 ms | 0 KB | - |