답안 #90656

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90656 2018-12-23T09:12:24 Z adlet Gift (IZhO18_nicegift) C++17
7 / 100
2000 ms 3684 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);

struct item {
    int x, i, j;
};

vector < item > ans;

pair < int, int > a[N];

int n, k, mx;

ll sum;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].first;
        sum += a[i].first;
        mx = max(mx, a[i].first);
        a[i].second = i;
    }
    if (sum % k != 0 || mx > sum / k) {
        cout << -1;
        return 0;
    }
    while (sum > 0)
    for (int i = 1; i <= n; ++i) {
        if (!a[i].first)
            continue;
        for (int j = n; j > i; --j) {
            if (!a[i].first)
                break;
            if (!a[j].first)
                continue;
            int x = 1;
            ans.push_back({1, a[i].second, a[j].second});
            a[i].first -= x;
            a[j].first -= x;
            sum -= 2 * x;
        }
    }
    cout << ans.size() << "\n";
    for (auto it : ans) {
        cout << it.x << " " << it.i << " " << it.j << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 508 KB n=3
3 Correct 2 ms 508 KB n=3
4 Correct 2 ms 508 KB n=4
5 Correct 2 ms 508 KB n=4
6 Correct 2 ms 548 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 508 KB n=3
3 Correct 2 ms 508 KB n=3
4 Correct 2 ms 508 KB n=4
5 Correct 2 ms 508 KB n=4
6 Correct 2 ms 548 KB n=2
7 Execution timed out 2064 ms 548 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 508 KB n=3
3 Correct 2 ms 508 KB n=3
4 Correct 2 ms 508 KB n=4
5 Correct 2 ms 508 KB n=4
6 Correct 2 ms 548 KB n=2
7 Execution timed out 2064 ms 548 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 3684 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 508 KB n=3
3 Correct 2 ms 508 KB n=3
4 Correct 2 ms 508 KB n=4
5 Correct 2 ms 508 KB n=4
6 Correct 2 ms 548 KB n=2
7 Execution timed out 2064 ms 548 KB Time limit exceeded
8 Halted 0 ms 0 KB -