답안 #370034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
370034 2021-02-23T02:38:31 Z azberjibiou Naan (JOI19_naan) C++17
0 / 100
2 ms 500 KB
#include <bits/stdc++.h>
#define gibon ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
#define fir first
#define sec second
#define ll long long
#define pii pair<int, int>
const int mxN=2020;
typedef struct frac{
    ll ja, mo;
}frac;
ll N, L;
ll V[mxN][mxN];
frac ans[mxN][mxN];
ll sum[mxN];
bool Chk[mxN];
queue <int> que;
frac mnus(frac a, frac b)
{
    frac res={a.ja*b.mo-a.mo*b.ja, a.mo*b.mo};
    if(res.mo<0)    res.mo*=-1, res.ja*=-1;
    return res;
}
bool cmp(frac a, frac b)
{
    return mnus(a, b).ja<0;
}
int main()
{
    gibon
    cin >> N >> L;
    for(int i=1;i<=N;i++)   for(int j=1;j<=L;j++)   cin >> V[i][j];
    for(int i=1;i<=N;i++)   for(int j=1;j<=L;j++)   sum[i]+=V[i][j];
    for(int i=1;i<=N;i++)
    {
        int now=0;
        int cnt=1;
        for(int j=1;j<=N;j++)
        {
            ll tot=sum[i];
            while(tot>N*V[i][cnt]-now)
            {
                tot-=N*V[i][cnt]-now;
                now=0;
                cnt++;
            }
            now+=tot;
            ans[i][j].mo=N*V[i][cnt];
            ans[i][j].ja=now+ans[i][j].mo*(cnt-1);
        }
    }
    for(int i=1;i<N;i++)
    {
        int pos=-1;
        for(int j=1;j<=N;j++)
        {
            if(Chk[j])  continue;
            if(pos==-1) pos=j;
            else if(cmp(ans[i][j], ans[i][pos]))    pos=j;
        }
        cout << ans[i][pos].ja << " " << ans[i][pos].mo << '\n';
        que.push(pos);
        Chk[pos]=true;
    }
    for(int i=1;i<=N;i++)    if(!Chk[i]) que.push(i);
    while(!que.empty())
    {
        cout << que.front() << " ";
        que.pop();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Not a fair distribution.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 2 ms 500 KB Output is correct
23 Incorrect 1 ms 364 KB Not a fair distribution.
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Not a fair distribution.
2 Halted 0 ms 0 KB -