結果
問題 | No.202 1円玉投げ |
ユーザー |
![]() |
提出日時 | 2017-03-14 22:37:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 772 ms / 5,000 ms |
コード長 | 1,329 bytes |
コンパイル時間 | 808 ms |
コンパイル使用メモリ | 75,380 KB |
実行使用メモリ | 5,716 KB |
最終ジャッジ日時 | 2024-12-22 10:55:49 |
合計ジャッジ時間 | 6,378 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int dist(pair<int, int>a, pair<int, int>b) { return (a.first - b.first)*(a.first - b.first) + (a.second - b.second)*(a.second - b.second); } int main() { int n;cin >> n; vector<pair<pair<int, int>, int>>sorted_pos; vector<pair<int, int>>pos; for (int i = 0;i < n;i++) { int x, y;cin >> x >> y; pos.push_back(make_pair(x, y)); sorted_pos.push_back(make_pair(make_pair(x, y), i)); } sort(sorted_pos.begin(), sorted_pos.end()); vector<int>sorted_index(n); for (int i = 0;i < n;i++) { sorted_index[sorted_pos[i].second] = i; } vector<bool>exist(n, true); for (int i = 0;i < n;i++) { int pos = sorted_index[i]; if (exist[pos] == false)continue; for (int j = pos + 1;j < sorted_pos.size();j++) { if (dist(sorted_pos[j].first, sorted_pos[pos].first) >= 400) { if (sorted_pos[j].first.first - sorted_pos[pos].first.first > 20)break; continue; } else exist[j] = false; } for (int j = pos - 1;j >= 0;j--) { if (dist(sorted_pos[j].first, sorted_pos[pos].first) >= 400) { if (sorted_pos[pos].first.first - sorted_pos[j].first.first > 20)break; continue; } else exist[j] = false; } } int cnt = 0; for (int i = 0;i < n;i++) { if (exist[i])cnt++; } cout << cnt << endl; return 0; }