Submission #378705

#TimeUsernameProblemLanguageResultExecution timeMemory
3787058e7Gift (IZhO18_nicegift)C++14
18 / 100
654 ms524292 KiB
//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 (stderr)

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++) {
      |                  ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...