結果
| 問題 |
No.1722 [Cherry 3rd Tune C] In my way
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2024-04-18 02:49:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,106 bytes |
| コンパイル時間 | 989 ms |
| コンパイル使用メモリ | 84,868 KB |
| 最終ジャッジ日時 | 2025-02-21 02:57:38 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
vector<pair<u64,u64>> factorize(u64 n){
vector<pair<u64,u64>> res;
for(u64 i=2; i*i<=n; i++){
if(n%i) continue;
res.push_back({i,0});
while(n%i==0){ n/=i; res.back().second++; }
}
if(n!=1) res.push_back({n,1});
return move(res);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int num_people; cin >> num_people;
int num_walls; cin >> num_walls;
vector<int> pos_people(num_people);
for(int& a : pos_people) cin >> a;
vector<int> pos_walls(num_walls);
for(int& a : pos_walls) cin >> a;
sort(pos_walls.begin(), pos_walls.end());
for(int& x : pos_people){
auto first_hit = lower_bound(pos_walls.begin(), pos_walls.end(), x) - pos_walls.begin();
if(first_hit == pos_walls.size()){
cout << "Infinity\n";
}
else{
auto pos_hit = pos_walls[first_hit];
int ans = pos_hit - x;
cout << ans << "\n";
}
}
return 0;
}
Nachia