mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 21:28:48 +00:00
F - Distance Sums
https://atcoder.jp/contests/arc103/submissions/36976350
This commit is contained in:
parent
8f66b7d8bb
commit
810be8ed7d
56
AtCoder/ARC103/F/F.cpp
Normal file
56
AtCoder/ARC103/F/F.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e5 + 5;
|
||||
|
||||
int n, siz[N];
|
||||
long long dis;
|
||||
std::pair<long long, int> d[N];
|
||||
std::vector<std::pair<int, int>> ans;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> d[i].first;
|
||||
|
||||
d[i].second = i;
|
||||
}
|
||||
|
||||
std::fill(siz + 1, siz + 1 + n, 1);
|
||||
std::sort(d + 1, d + 1 + n);
|
||||
|
||||
for (int i = n; i > 1; i--) {
|
||||
long long t = d[i].first - n + (siz[i] << 1);
|
||||
int p = std::lower_bound(d + 1, d + 1 + n, std::make_pair(t, 0)) - d;
|
||||
|
||||
if (d[p].first != t) {
|
||||
cout << -1 << endl;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
ans.emplace_back(d[i].second, d[p].second);
|
||||
siz[p] += siz[i];
|
||||
dis += siz[i];
|
||||
}
|
||||
|
||||
if (dis != d[1].first) {
|
||||
cout << -1 << endl;
|
||||
} else {
|
||||
for (auto e : ans) {
|
||||
cout << e.first << ' ' << e.second << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
AtCoder/ARC103/F/data/1.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/1.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/10.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/10.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/11.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/11.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/12.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/12.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/13.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/13.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/14.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/14.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/15.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/15.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/16.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/16.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/17.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/17.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/18.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/18.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/18.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/19.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/19.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/2.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/2.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/20.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/20.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/20.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/21.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/21.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/21.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/21.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/22.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/22.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/22.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/22.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/23.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/23.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/23.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/23.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/24.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/24.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/24.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/24.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/25.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/25.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/25.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/25.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/26.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/26.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/26.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/26.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/27.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/27.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/27.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/27.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/28.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/28.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/28.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/28.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/29.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/29.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/29.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/29.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/3.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/3.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/30.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/30.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/30.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/30.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/31.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/31.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/31.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/31.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/32.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/32.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/32.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/32.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/33.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/33.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/33.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/33.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/34.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/34.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/34.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/34.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/35.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/35.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/35.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/35.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/36.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/36.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/36.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/36.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/37.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/37.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/37.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/37.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/38.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/38.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/38.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/38.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/39.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/39.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/39.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/39.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/4.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/4.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/40.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/40.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/40.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/40.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/41.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/41.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/41.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/41.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/42.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/42.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/42.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/42.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/5.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/5.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/6.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/6.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/7.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/7.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/8.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/8.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/9.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/9.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/sample1.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/sample1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/sample1.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/sample1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/sample2.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/sample2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/sample2.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/sample2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/sample3.in
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/sample3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
AtCoder/ARC103/F/data/sample3.out
(Stored with Git LFS)
Normal file
BIN
AtCoder/ARC103/F/data/sample3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user