답안 #644134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644134 2022-09-24T01:19:10 Z Do_you_copy Gift (IZhO18_nicegift) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>#define int long long#define fi first#define se secondusing namespace std;using ll = long long;using pii = pair <int, int>;#define pb push_backconst int maxN = 1e6 + 10;const int maxOP = 3e6;int n, k;int a[maxN];priority_queue <pii> PQ;vector <vector <int>> e;void Init(){    cin >> n >> k;    for (int i = 1; i <= n; ++i){        cin >> a[i];        PQ.push({a[i], i});    }    for (int i = 1; i * k <= maxOP; ++i){        vector <int> pos;        for (int j = 0; j < k; ++j){            pos.pb(PQ.top().se);            PQ.pop();        }        if (!a[pos.back()]) break;        e.pb({a[pos.back()]});        for (int j = 0; j < k; ++j){            e.back().pb(pos[j]);            a[pos[j]] -= a[pos.back()];        }        for (int j = 0; j < k; ++j){            PQ.push({a[pos[j]], pos[j]});        }    }    for (int i = 1; i <= n; ++i){        if (a[i]){            cout << -1; return;        }    }    cout << e.size() << "\n";    for (auto &i: e){        for (auto &j: i) cout << j << " ";        cout << "\n";    }}signed main() {    Init();}

Compilation message

nicegift.cpp:1:25: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>#define int long long#define fi first#define se secondusing namespace std;using ll = long long;using pii = pair <int, int>;#define pb push_backconst int maxN = 1e6 + 10;const int maxOP = 3e6;int n, k;int a[maxN];priority_queue <pii> PQ;vector <vector <int>> e;void Init(){    cin >> n >> k;    for (int i = 1; i <= n; ++i){        cin >> a[i];        PQ.push({a[i], i});    }    for (int i = 1; i * k <= maxOP; ++i){        vector <int> pos;        for (int j = 0; j < k; ++j){            pos.pb(PQ.top().se);            PQ.pop();        }        if (!a[pos.back()]) break;        e.pb({a[pos.back()]});        for (int j = 0; j < k; ++j){            e.back().pb(pos[j]);            a[pos[j]] -= a[pos.back()];        }        for (int j = 0; j < k; ++j){            PQ.push({a[pos[j]], pos[j]});        }    }    for (int i = 1; i <= n; ++i){        if (a[i]){            cout << -1; return;        }    }    cout << e.size() << "\n";    for (auto &i: e){        for (auto &j: i) cout << j << " ";        cout << "\n";    }}signed main() {    Init();}
      |                         ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status