Submission #733898

#TimeUsernameProblemLanguageResultExecution timeMemory
733898vjudge1Lightning Rod (NOI18_lightningrod)C++17
44 / 100
2035 ms144084 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { int t, n, m, ans, i, z,j, x, r, p, s, y; cin >> n; vector < pair < int, int > > v; ans = 0; r= 1e9; p = -1e9; s = 0; for ( i = 1; i <= n; i ++) { scanf("%d",& x); scanf("%d",& y); if ( x == i) s ++; v.push_back(make_pair(2 * y, x - y)); p = max (p, y); r = min(r, y); } if ( r == 1 && p == 1) { cout << n << endl; return 0; } if ( r == 0 && p == 1 && s == n) { vector < int > q; for ( i = 1; i <= n; i ++) { q.push_back(v[i].first/2); } ans = 1; for ( j = 0; j < q.size() - 1; j ++) { if ( q[j] == q[j + 1]) ans ++; } cout << ans << endl; return 0; } 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:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for ( j = 0; j < q.size() - 1; j ++) {
      |                ~~^~~~~~~~~~~~~~
lightningrod.cpp:42: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]
   42 |   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, r, p, s, y;
      |      ^
lightningrod.cpp:6:12: warning: unused variable 'm' [-Wunused-variable]
    6 |  int t, n, m, ans, i, z,j, x, r, p, s, y;
      |            ^
lightningrod.cpp:6:23: warning: unused variable 'z' [-Wunused-variable]
    6 |  int t, n, m, ans, i, z,j, x, r, p, s, y;
      |                       ^
lightningrod.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d",& x);
      |   ~~~~~^~~~~~~~~~
lightningrod.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   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...