Submission #54228754
Source Code Expand
#pragma GCC optimize(2,3,"Ofast","inline")
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+10;
int n;
int a[maxn];
ll ans;
inline int erfen(int x){
int l=1,r=n,res=0;
while(l<=r){
int mid=(l+r)>>1;
if(a[mid]>x){l=mid+1;res=mid;}
else r=mid-1;
}
return res;
}
signed main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
sort(a+1,a+n+1,greater<int>());
for(int i=1;i<=n;i++){
int now=n;
while(now>i){
int k=a[i]/a[now];
int nxt=erfen(a[i]/k);
if(nxt<=i||nxt>n) nxt=i;
ans+=1ll*(now-nxt)*k;
now=nxt;
}
}
printf("%lld\n",ans);
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Max/Min |
| User | yaohaoyou |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 761 Byte |
| Status | TLE |
| Exec Time | 2210 ms |
| Memory | 4532 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:19:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
Main.cpp:20:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | for(int i=1;i<=n;i++) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 475 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | min_01.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| min_01.txt | AC | 5 ms | 3628 KiB |
| random_01.txt | TLE | 2207 ms | 4184 KiB |
| random_02.txt | AC | 1490 ms | 4024 KiB |
| random_03.txt | TLE | 2207 ms | 4112 KiB |
| random_04.txt | TLE | 2207 ms | 4104 KiB |
| random_05.txt | TLE | 2207 ms | 4160 KiB |
| random_06.txt | TLE | 2210 ms | 4028 KiB |
| random_07.txt | TLE | 2207 ms | 4268 KiB |
| random_08.txt | AC | 873 ms | 3764 KiB |
| random_09.txt | TLE | 2206 ms | 4272 KiB |
| random_10.txt | TLE | 2210 ms | 3744 KiB |
| random_11.txt | TLE | 2207 ms | 4172 KiB |
| random_12.txt | TLE | 2207 ms | 4000 KiB |
| random_13.txt | TLE | 2094 ms | 4420 KiB |
| random_14.txt | AC | 1166 ms | 4272 KiB |
| random_15.txt | TLE | 2185 ms | 4468 KiB |
| random_16.txt | AC | 696 ms | 4200 KiB |
| random_17.txt | AC | 14 ms | 4532 KiB |
| random_18.txt | AC | 19 ms | 4388 KiB |
| random_19.txt | AC | 18 ms | 4500 KiB |
| random_20.txt | AC | 38 ms | 4424 KiB |
| random_21.txt | TLE | 2207 ms | 4120 KiB |
| sample_01.txt | AC | 1 ms | 3808 KiB |
| sample_02.txt | AC | 1 ms | 3692 KiB |
| sample_03.txt | AC | 1 ms | 3772 KiB |