Submission #733844

#TimeUsernameProblemLanguageResultExecution timeMemory
733844vjudge1Lightning Rod (NOI18_lightningrod)C++17
40 / 100
2078 ms131720 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
int main() {
	int t, n, m, ans, i, z,j, x, y;
	
	cin >> n;
	vector < pair < int, int > > v;
	ans = 0;
	for ( i = 1; i <= n; i ++) {
		scanf("%d",& x);
		scanf("%d",& y);
		v.push_back(make_pair(2 * y, x - y));
	}
	sort ( v.begin(), v.end());
	for ( i = v.size() - 1; i >= 0; i -- ) {
		ans ++;
		for ( j = i + 1; j < v.size(); j ++) {
			if ( v[j].second <= v[i].second && (v[j].second + v[j].first) >= (v[i].second + v[i].first)) {
				ans --;
				break;
			}			
		}
	}
	cout << ans << endl;
}

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for ( j = i + 1; j < v.size(); j ++) {
      |                    ~~^~~~~~~~~~
lightningrod.cpp:6:6: warning: unused variable 't' [-Wunused-variable]
    6 |  int t, n, m, ans, i, z,j, x, y;
      |      ^
lightningrod.cpp:6:12: warning: unused variable 'm' [-Wunused-variable]
    6 |  int t, n, m, ans, i, z,j, x, y;
      |            ^
lightningrod.cpp:6:23: warning: unused variable 'z' [-Wunused-variable]
    6 |  int t, n, m, ans, i, z,j, x, y;
      |                       ^
lightningrod.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d",& x);
      |   ~~~~~^~~~~~~~~~
lightningrod.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d",& y);
      |   ~~~~~^~~~~~~~~~
#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...