답안 #312236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312236 2020-10-12T20:36:06 Z aryan12 Gift (IZhO18_nicegift) C++17
0 / 100
33 ms 12780 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int f = 1, s = 2;
    vector<pair<int, pair<int, int> > >ans;
    while(f <= n && s <= n) {
        if(a[f] > a[s]) {
            a[f] -= a[s];
            ans.push_back({a[s], {f, s}});
            s = max(s, f) + 1;
        }
        else if(a[f] == a[s]) {
            ans.push_back({a[f], {f, s}});
            f = max(s, f) + 1;
            s = f + 1;
        }
        else {
            a[s] -= a[f];
            ans.push_back({a[f], {f, s}});
            f = max(s, f) + 1;
        }
    }
    if(f <= n || s <= n) {
        cout << "-1" << endl;
    }
    else {
        cout << ans.size() << endl;
        for(int i = 0; i < ans.size(); i++) {
            cout << ans[i].first << " " << ans[i].second.first << " " << ans[i].second.second << endl;
        }
    }
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:35:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int i = 0; i < ans.size(); i++) {
      |                        ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n=4
2 Correct 0 ms 256 KB n=3
3 Correct 1 ms 384 KB n=3
4 Incorrect 0 ms 384 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n=4
2 Correct 0 ms 256 KB n=3
3 Correct 1 ms 384 KB n=3
4 Incorrect 0 ms 384 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n=4
2 Correct 0 ms 256 KB n=3
3 Correct 1 ms 384 KB n=3
4 Incorrect 0 ms 384 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 12780 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n=4
2 Correct 0 ms 256 KB n=3
3 Correct 1 ms 384 KB n=3
4 Incorrect 0 ms 384 KB Jury has the answer but participant has not
5 Halted 0 ms 0 KB -