# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1166754 | shidou26 | Lightning Rod (NOI18_lightningrod) | C++17 | 1099 ms | 78304 KiB |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define filter(v) v.resize(unique(all(v)) - v.begin())
#define dbg(v) "[" #v " = " << (v) << "]"
template<typename T> bool maximize(T &a, T b) {
if(a < b) {
a = b;
return true;
}else return false;
}
template<typename T> bool minimize(T &a, T b) {
if(a > b) {
a = b;
return true;
}else return false;
}
typedef long long ll;
typedef long double ld;
const int N = 1e7 + 3;
int n;
pair<int, int> rods[N];
bool mark[N];
void process() {
sort(rods + 1, rods + 1 + n, [](pair<int, int> a, pair<int, int> b){
return (a.second == b.second ? a.first < b.first : a.second > b.second);
});
for(int i = 1; i <= n; i++) {
mark[i] = true;
for(int j = 1; j < i; j++) if(mark[j] && abs(rods[i].first - rods[j].first) <= rods[j].second - rods[i].second) {
mark[i] = false;
break;
}
}
int answer = 0;
for(int i = 1; i <= n; i++) answer += mark[i];
cout << answer << endl;
}
void input() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> rods[i].first >> rods[i].second;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#define task "DateALive"
if(fopen(task".INP", "r")) {
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
int testcase = 1; // cin >> testcase;
for(int i = 1; i <= testcase; i++) {
input();
process();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |