답안 #251867

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251867 2020-07-22T13:07:12 Z dantoh000 Naan (JOI19_naan) C++14
0 / 100
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 = {1,0};
        int cur;
        for (int j = 1; j <= n; j++){
            if (vis[j] == 0){
                if ((__int128)best.first*p[i][j].second > (__int128)best.second*p[i][j].first){
                    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

naan.cpp: In function 'int main()':
naan.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&l);
     ~~~~~^~~~~~~~~~~~~~
naan.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld",&a[j]);
             ~~~~~^~~~~~~~~~~~~~
naan.cpp:39:16: warning: 'cur' may be used uninitialized in this function [-Wmaybe-uninitialized]
         ord[i] = cur;
         ~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 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 1 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 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 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 0 ms 384 KB Not a fair distribution.
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Not a fair distribution.
2 Halted 0 ms 0 KB -