LoginSignup
0

More than 5 years have passed since last update.

北大・日立新概念コンピューティングコンテスト2018で正の点数が取りたい

Last updated at Posted at 2019-02-15

現在、コンテスト中です。

問題はこれ
https://atcoder.jp/contests/hokudai-hitachi2018

とりあえず正の点数が取りたい人向け。
ご自由にご利用ください。

続きの記事 → https://qiita.com/nekomimimi/items/94c85a2d263734ea2f19

#include <iostream>
#include <vector>
#include <cmath>
// 北大・日立新概念コンピューティングコンテスト2018

// 目標
// なんでもいいからA,B,Cで正の得点が取りたい
//
// 方針
// 次数が1か2であれば、そのまま入力の項を出力すればいい。
// よって、次数が3次以上を考えればいい。
// 入力f以上の値で、出力gをできるだけ小さくしたい。
// 1. 係数cが0以下の項はとりあえず無視する。
// 2. cが1以上の時は、足して定数として出力。

using namespace std;
int main() {
    int N;
    int K;

    // input
    cin >> N >> K;

    vector< vector<int> > v;
    vector<int> c;

    int c_d0 = 0;

    for (int i = 0; i < K; i++) {
        int d;
        int ct;

        cin >> d >> ct;
        c.push_back(ct);
        vector<int> v_row;

        for (int j = 0; j < d; j++) {
            int cur;
            cin >> cur;
            v_row.push_back(cur);
        }

        v.push_back(v_row);
    }

    // 計算
    vector< vector<int> > v_ret;
    vector<int> c_ret;

    int total_c = 0;

    for (int i = 0; i < K; i++) {
        if (v[i].size() > 0 && v[i].size() <= 2) {
            v_ret.push_back(v[i]);
            c_ret.push_back(c[i]);
        } else {
            total_c += max(0, c[i]);
        }
    }

    // output
    cout << N << " " <<  v_ret.size() + 1  << endl;

    cout << "0 " << max(1,total_c) <<  endl;
    for (int i = 0; i < v_ret.size(); i++) {
        cout << v_ret[i].size() << " " << c_ret[i];
        for (int cur : v_ret[i]) {
            cout << " "  << cur;
        }
        cout << endl;
    }

    return 0;
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0