# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
378841 |
2021-03-17T05:57:33 Z |
wiwiho |
Gift (IZhO18_nicegift) |
C++14 |
|
456 ms |
61852 KB |
#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;
}
for(int i = 0; i < n; i++){
if(a[i].F != 0){
cout << "-1\n";
return 0;
}
}
cout << ans.size() << "\n";
for(auto& i : ans){
cout << i.F << " ";
printv(i.S, cout);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Incorrect |
0 ms |
364 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Incorrect |
0 ms |
364 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Incorrect |
0 ms |
364 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
456 ms |
61852 KB |
n=1000000 |
2 |
Incorrect |
287 ms |
41400 KB |
Expected int32, but "1500001500001" found |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Incorrect |
0 ms |
364 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |