Submission #824328

#TimeUsernameProblemLanguageResultExecution timeMemory
824328christinelynnLightning Rod (NOI18_lightningrod)C++17
100 / 100
659 ms246460 KiB
#include<bits/stdc++.h> using namespace std; const int INF=1e18; int n, ans; void read(int &in) { in=0; for(char c=getchar(); '0'<=c && c<='9'; c=getchar()) in=10*in+c-'0'; } void post(int out) { char dig[11]; int idx=0; do{ dig[idx++]='0'+out%10; out/=10; } while(out); idx--; while(idx>=0) putchar(dig[idx--]); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x, y, ans=0; read(n); pair<int, int> a[n]; int temp=-INF; for(int i=0; i<n; i++) { read(x); read(y); a[i].second=x-y; if(x+y<=temp) a[i].first=0; else a[i].first=1; temp=max(temp, x+y); } temp=INF; for(int i=n-1; i>=0; i--) { if(a[i].second<temp) ans+=a[i].first; temp=min(temp, a[i].second); } post(ans); putchar('\n'); return 0; }

Compilation message (stderr)

lightningrod.cpp:3:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    3 | const int INF=1e18;
      |               ^~~~
#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...