結果
| 問題 | No.3527 Minimum Abs Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-13 11:06:13 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 896 bytes |
| 記録 | |
| コンパイル時間 | 4,600 ms |
| コンパイル使用メモリ | 386,924 KB |
| 実行使用メモリ | 12,836 KB |
| 最終ジャッジ日時 | 2026-11-13 11:06:47 |
| 合計ジャッジ時間 | 9,882 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#if __has_include("all.hpp")
#include "all.hpp"
#else
#include <atcoder/all>
#endif
using namespace atcoder;
using mint =modint1000000007;
struct R{
//>=0&&de!=0
long long nu,de;
bool operator<(const R& other) const {
return (__int128)nu*other.de<(__int128)de*other.nu;
}
};
int main(void){
int n;
cin>>n;
long long sum=0;
vector<pair<R,int>>d;
vector<int>a(n),b(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)cin>>b[i];
for(int i=0;i<n;i++){
if(a[i]==0)continue;
d.push_back({{b[i],a[i]},abs(a[i])});
sum+=a[i];
}
sort(d.begin(),d.end());
sum/=2;
for(int i=0;i<d.size();i++){
sum-=d[i].second;
if(sum<0){
cout<<((mint)d[i].first.nu/(mint)d[i].first.de).val()<<endl;
break;
}
}
return 0;
}