Submission #1166718

#TimeUsernameProblemLanguageResultExecution timeMemory
1166718shidou26Lightning Rod (NOI18_lightningrod)C++20
40 / 100
1098 ms78412 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; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:65:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |                 freopen(task".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:66:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |                 freopen(task".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...