제출 #1368703

#제출 시각아이디문제언어결과실행 시간메모리
1368703chikien2009Naan (JOI19_naan)C++20
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>

using namespace std;

void setup()
{
#ifndef ONLINE_JUDGE
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int n, m, id;
long long sum, cur, temp;
long long v[2000][2000];
pair<long long, long long> f[2000][2000];
bool removed[2000];
vector<int> res;

int main()
{
    setup();

    cin >> n >> m;
    for (int i = 0; i < n; ++i)
    {
        sum = cur = 0;
        for (int j = 0; j < m; ++j)
        {
            cin >> v[i][j];
            sum += v[i][j];
            v[i][j] *= n;
        }
        for (int j = 0, k = 0; j < n; ++j)
        {
            temp = sum;
            while (temp && k < m)
            {
                if (temp > v[i][k] - cur)
                {
                    temp -= v[i][k] - cur;
                    cur = 0;
                    k++;
                }
                else
                {
                    cur += temp;
                    temp = 0;
                }
            }
            f[i][j] = {v[i][k] * k + cur, v[i][k]};
        }
    }
    for (int i = 0; i < n - 1; ++i)
    {
        id = -1;
        for (int j = 0; j < n; ++j)
        {
            if (!removed[j])
            {
                if (id == -1 || (double)f[id][i].first / (double)f[id][i].second >
                                    (double)f[j][i].first / (double)f[j][i].second)
                {
                    id = j;
                }
            }
        }
        removed[id] = true;
        res.push_back(id + 1);
        cout << f[id][i].first << " " << f[id][i].second << "\n";
    }
    for (int i = 0; i < n; ++i)
    {
        if (!removed[i])
        {
            res.push_back(i + 1);
        }
    }
    for (auto & i : res)
    {
        cout << i << " ";
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

naan.cpp: In function 'void setup()':
naan.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen("test.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
naan.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("test.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…