Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
156750 刘轻松 两个数的最小距离II C++ Accepted 2 MS 276 KB 359 2026-07-10 13:42:33

Tests(15/15):


Code:

#include<bits/stdc++.h> using namespace std; long long a[1005]; int main(){ int n,x,y; long long min = 1e18,k; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ k = abs(a[i]-a[j]); if(k<min){ min = k; x = i; y = j; } } } cout<<x<<" "<<y; return 0; }