답안 #378705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
378705 2021-03-17T03:24:38 Z 8e7 Gift (IZhO18_nicegift) C++14
18 / 100
654 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);
		}
	}
	bool poss = val.size() % 2 == 0;
	for (int i = 0;i < val.size() / 2;i++) {
		if (val[i] == val[i + val.size() / 2]) {
			poss = false;
			break;
		}
	}
	if (!poss) {
		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:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for (int i = 0;i < val.size() / 2;i++) {
      |                 ~~^~~~~~~~~~~~~~~~
nicegift.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   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 0 ms 364 KB n=4
5 Correct 0 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 0 ms 364 KB n=4
5 Correct 0 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 364 KB n=5
8 Correct 1 ms 1008 KB n=8
9 Correct 5 ms 748 KB n=14
10 Correct 3 ms 620 KB n=11
11 Correct 19 ms 2028 KB n=50000
12 Correct 18 ms 1900 KB n=50000
13 Correct 14 ms 1260 KB n=10
14 Correct 13 ms 1260 KB n=685
15 Correct 14 ms 1260 KB n=623
16 Correct 8 ms 880 KB n=973
# 결과 실행 시간 메모리 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 0 ms 364 KB n=4
5 Correct 0 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 364 KB n=5
8 Correct 1 ms 1008 KB n=8
9 Correct 5 ms 748 KB n=14
10 Correct 3 ms 620 KB n=11
11 Correct 19 ms 2028 KB n=50000
12 Correct 18 ms 1900 KB n=50000
13 Correct 14 ms 1260 KB n=10
14 Correct 13 ms 1260 KB n=685
15 Correct 14 ms 1260 KB n=623
16 Correct 8 ms 880 KB n=973
17 Incorrect 14 ms 1388 KB Same heap occurs twice
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 654 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 0 ms 364 KB n=4
5 Correct 0 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 364 KB n=5
8 Correct 1 ms 1008 KB n=8
9 Correct 5 ms 748 KB n=14
10 Correct 3 ms 620 KB n=11
11 Correct 19 ms 2028 KB n=50000
12 Correct 18 ms 1900 KB n=50000
13 Correct 14 ms 1260 KB n=10
14 Correct 13 ms 1260 KB n=685
15 Correct 14 ms 1260 KB n=623
16 Correct 8 ms 880 KB n=973
17 Incorrect 14 ms 1388 KB Same heap occurs twice
18 Halted 0 ms 0 KB -