結果
| 問題 |
No.2999 Long Long Friedrice
|
| コンテスト | |
| ユーザー |
asmin
|
| 提出日時 | 2025-01-18 15:55:47 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 1,752 bytes |
| コンパイル時間 | 4,896 ms |
| コンパイル使用メモリ | 284,412 KB |
| 実行使用メモリ | 11,236 KB |
| 最終ジャッジ日時 | 2025-01-18 15:56:08 |
| 合計ジャッジ時間 | 6,566 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 33 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
//using ar2 = array<ll, 2>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pop_cnt(s) ll(popcount(uint64_t(s)))
#define next_p(v) next_permutation(v.begin(), v.end())
template <typename T> inline bool chmin(T& a, const T& b) {bool c=a>b; if(a>b) a=b; return c;}
template <typename T> inline bool chmax(T& a, const T& b) {bool c=a<b; if(a<b) a=b; return c;}
template <typename T> inline T gcd(T a,T b) {return (b==0)?a:gcd(b,a%b);}
template <typename T> inline T lcm(T a, T b) {return (a*b)/gcd(a,b);}
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vc<vc<T>>;
template <typename T> using vvvc = vc<vvc<T>>;
template <class T> using pq = priority_queue<T, vc<T>>;
template <class T> using pq_g = priority_queue<T, vc<T>, greater<T>>;
const ll INF = 2e18;
const vc<ll> dx = {1, 0, -1, 0};
const vc<ll> dy = {0, 1, 0, -1};
//ライブラリ貼るところ
//ここまで
void solve(){
int n;
cin >> n;
vc<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];
vc<pair<int, int>> p(n);
for(int i = 0; i < n; ++i) p[i] = {a[i], b[i]};
sort(all(p));
vc<int> ok(2000000, 0);
ok[1] = 1;
int ans = 1;
for(int i = 0; i < n; ++i){
if(ok[p[i].first] == 1){
ok[p[i].first + p[i].second] = 1;
chmax(ans, p[i].first + p[i].second);
}
}
cout << ans << "\n";
}
int main(){
cin.tie( nullptr );
ios::sync_with_stdio( false );
cout << setprecision( 20 ) << fixed;
int t = 1;
for(int i = 0; i < t; ++i) solve();
}
asmin