Submission #1208041

#TimeUsernameProblemLanguageResultExecution timeMemory
1208041quangminh412Advertisement 2 (JOI23_ho_t2)C++17
59 / 100
56 ms4608 KiB
#include <bits/stdc++.h> using namespace std; /* Ben Watson Handle codeforces : quangminh98 Mua Code nhu mua Florentino !! */ #define ll long long const string name = "test"; void solve(); signed main() { if (fopen((name + ".inp").c_str(), "r")) { freopen((name + ".inp").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; } // main program bool cmp(pair<int, int> a, pair<int, int> b) { if (a.first == b.first) return a.second >= b.second; return a.first < b.first; } void solve() { int n; cin >> n; vector<pair<int, int>> books; for (int i = 0; i < n; i++) { int x, e; cin >> x >> e; books.push_back({x - e, x + e}); } sort(books.begin(), books.end(), cmp); int res = 0, mx = -1; for (pair<int, int> it : books) if (mx < it.second) { mx = it.second; res++; } cout << res << '\n'; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen((name + ".inp").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen((name + ".out").c_str(), "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...