This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const ll MAX = 1LL << 60;
ostream& operator<<(ostream& o, pll p){
return o << '(' << p.F << ',' << p.S << ')';
}
ll iceil(ll a, ll b){
return (a + b - 1) / b;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n, k;
cin >> n >> k;
vector<pll> a(n);
for(int i = 0; i < n; i++){
cin >> a[i].F;
a[i].S = i + 1;
}
sort(a.begin(), a.end(), greater<>());
vector<pair<ll, vector<int>>> ans;
int lst = 0;
for(int i = 1; i < n; i++){
while(a[lst].F == 0) lst++;
if(i == lst) continue;
a[lst].F -= a[i].F;
ans.eb(mp(a[i].F, vector<int>()));
ans.back().S.eb(a[lst].S);
ans.back().S.eb(a[i].S);
a[i].F = 0;
}
cout << ans.size() << "\n";
for(auto& i : ans){
cout << i.F << " ";
printv(i.S, cout);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |