답안 #378702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378702 2021-03-17T03:23:36 Z 8e7 Gift (IZhO18_nicegift) C++14
7 / 100
669 ms 524292 KB
//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#define ll long long
#define maxn 1000005
#define pii pair<int, ll>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
ll a[maxn];
vector<int> val;
int main() {
	io
	ll n, k;
	cin >> n >> k;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		for (int j = 0;j < a[i];j++) {
			val.push_back(i);
		}
	}
	if (val.size() % 2) {
		cout << -1 << endl;
	} else {
		cout << val.size() / 2 << "\n";
		for (int i = 0;i < val.size() / 2;i++) {
			cout << 1 << " " << val[i]+1 << " " << val[i + val.size() / 2]+1 << "\n";
		}
	}
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for (int i = 0;i < val.size() / 2;i++) {
      |                  ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Correct 1 ms 364 KB n=3
4 Correct 1 ms 364 KB n=4
5 Correct 1 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Correct 1 ms 364 KB n=3
4 Correct 1 ms 364 KB n=4
5 Correct 1 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 492 KB n=5
8 Incorrect 9 ms 1008 KB Same heap occurs twice
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Correct 1 ms 364 KB n=3
4 Correct 1 ms 364 KB n=4
5 Correct 1 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 492 KB n=5
8 Incorrect 9 ms 1008 KB Same heap occurs twice
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 669 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Correct 1 ms 364 KB n=3
4 Correct 1 ms 364 KB n=4
5 Correct 1 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 492 KB n=5
8 Incorrect 9 ms 1008 KB Same heap occurs twice
9 Halted 0 ms 0 KB -