Submission #733885

# Submission time Handle Problem Language Result Execution time Memory
733885 2023-05-01T11:33:46 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
Compilation error
0 ms 0 KB
#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() + i + 1)/2; j ++) {
			p = v.size() - (j - i);
			if ( v[j].second <= v[i].second && (v[j].second + v[j].first) >= (v[i].second + v[i].first)) {
				ans --;
				break;
			}			
			if ( v[p].second <= v[p].second && (v[p].second + v[p].first) >= (v[i].second + v[i].first)) {
				ans --;
				break;
			}
		}
	}
	cout << ans << endl;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:20: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]
   20 |   for ( j = i + 1; j <= (v.size() + i + 1)/2; j ++) {
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~~
lightningrod.cpp:21:4: error: 'p' was not declared in this scope
   21 |    p = v.size() - (j - i);
      |    ^
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);
      |   ~~~~~^~~~~~~~~~