Submission #168918

#TimeUsernameProblemLanguageResultExecution timeMemory
168918abilGift (IZhO18_nicegift)C++14
0 / 100
2025 ms63868 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int a[N]; set<pair<int,int > > s; vector<pair<int,pair<int,int > > > vec; main() { int n, k, sum = 0; scanf("%d%d", &n, &k); for(int i = 1;i <= n; i++){ scanf("%d", &a[i]); sum += a[i]; s.insert({a[i], i}); } if(sum % k != 0){ cout << -1; return 0; } while(!s.empty()){ pair<int,int > x, y; x = *s.begin(); s.erase(s.begin()); y = *s.begin(); s.erase(s.begin()); vec.pb({x.fr, {x.sc, y.sc}}); if(y.fr - x.fr > 0){ s.insert({y.fr - x.fr, y.sc}); } } cout << vec.size() << endl; for(auto to : vec){ cout << to.fr << " " << to.sc.fr << " " << to.sc.sc << endl; } }

Compilation message (stderr)

nicegift.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
nicegift.cpp: In function 'int main()':
nicegift.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~
nicegift.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[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...