結果
| 問題 | No.3704 気まずいペア (Awkward Pairs) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-10 16:31:50 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 71 ms / 2,000 ms |
| + 600µs | |
| コード長 | 588 bytes |
| 記録 | |
| コンパイル時間 | 1,550 ms |
| コンパイル使用メモリ | 219,264 KB |
| 実行使用メモリ | 8,752 KB |
| 最終ジャッジ日時 | 2026-09-10 16:32:11 |
| 合計ジャッジ時間 | 10,003 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 小課題1 | 40 % | AC * 8 |
| 小課題2 | 60 % | AC * 12 |
| 合計 | 100 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<pair<int,int>> A(2*N);
for(int i=0; i<2*N; i++){
int a; cin >> a;
A.at(i) = {a,i};
}
sort(A.begin(),A.end());
vector<pair<int,int>> X;
long long answer = 0;
for(int i=0; i<N; i++){
auto [a1,p1] = A.at(i);
auto [a2,p2] = A.at(2*N-1-i);
answer += abs(a2-a1),X.push_back({p1,p2});
}
cout << answer << "\n";
for(auto [a,b] : X) cout << a+1 << " " << b+1 << "\n";
}