Submission #537456

#TimeUsernameProblemLanguageResultExecution timeMemory
537456tqbfjotldPlanine (COCI21_planine)C++14
0 / 110
3 ms724 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int X[1000005]; int Y[1000005]; bool cmp(pair<int,int> a, pair<int,int>b){ if (a.second==b.second) return a.first<b.first; else return a.second<b.second; } main(){ int n,h; scanf("%lld%lld",&n,&h); if (n==3){ printf("0"); return 0; } for (int x = 0; x<n; x++){ scanf("%lld%lld",&X[x],&Y[x]); } vector<pair<int,int> > v; for (int x = 2; x<n-1; x+=2){ v.push_back({X[x]-(h-Y[x])*(X[x]-X[x-1])/(Y[x-1]-Y[x]),X[x]+(h-Y[x])*(X[x+1]-X[x])/(Y[x+1]-Y[x])}); } sort(v.begin(),v.end(),cmp); int cur = v[0].second; int ans = 1; for (auto x : v){ //printf("interval %lld/%lld to %lld/%lld\n",x.first.a,x.first.b,x.second.a,x.second.b); if (x.first<=cur) continue; ans++; cur = x.second; } printf("%lld",ans); }

Compilation message (stderr)

Main.cpp:13:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 |  main(){
      |  ^~~~
Main.cpp: In function 'int main()':
Main.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%lld%lld",&n,&h);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%lld%lld",&X[x],&Y[x]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...