Submission #797236

#TimeUsernameProblemLanguageResultExecution timeMemory
797236dimasnbayuRabbit Carrot (LMIO19_triusis)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define start cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define endl '\n' #define pii pair<int,int> #define pll pair<long long, long long> #define fflush(stdout); cout.flush(); struct point{ int x, y; }; int crossproduct(point a, point b, point c){ //point a biasanya titik (0, 0); int area=(b.x-a.x) * (c.y-a.y) - (b.y-a.y) * (c.x-a.x); if(area<0) return -1; // clockwise else if(area>0) return 1; // counter clockwise return 0; // colinear } int orientation(point p1, point p2, point p3){ int val=(p2.y-p1.y)(p3.x-p2.x) - (p3.y-p2.y)(p2.x-p1.x); if(val==0) return 0; // colinear else if(val>0) return 1; // clockwise else return 2; // counter clockwise } bool validcolinear(int a, int b, int c, int d){ if(a>b) swap(a, b); if(c>d) swap(c, d); return max(a, c)<=min(b, d); } bool intersect(point a, point b, point c, point d){ int o1=orientation(a, b, c); int o2=orientation(a, b, d); int o3=orientation(c, d, a); int o4=orientation(c, d, b); if(o1!=o2 && o3!=o4) return 1; if(o1==0 && o2==0 && o3==0 && o4==0){ //all of 4 points are colinear if(validcolinear(a.x, b.x, c.x, d.x) && validcolinear(a.y, b.y, c.y, d.y)){ return 1; } } return 0; } /*********************************/ /*********************************/ int a[200005], b[200005]; int main(){ start int n, m; cin>>n>>m; for(int i=1;i<=n;i++){ cin>>a[i]; b[i]=(m*i)-a[i]; // if(b[i]<0) b[i]=0; } vector<int>v; // v.push_back(0); for(int i=1;i<=n;i++){ int x=b[i]; if(x<=0) continue; int l=0, r=v.size()-1; int idx=-1; while(l<=r){ int mid=(l+r)/2; if(x<=v[mid]){ r=mid-1; idx=mid; } else l=mid+1; } if(idx!=-1) v[idx]=x; else v.push_back(x); } int komp=v.size(); if(a[1]<=m) komp++; // if(komp==1) komp--; cout<<n-komp<<endl; }

Compilation message (stderr)

triusis.cpp: In function 'int orientation(point, point, point)':
triusis.cpp:23:31: error: expression cannot be used as a function
   23 |  int val=(p2.y-p1.y)(p3.x-p2.x) - (p3.y-p2.y)(p2.x-p1.x);
      |                               ^
triusis.cpp:23:56: error: expression cannot be used as a function
   23 |  int val=(p2.y-p1.y)(p3.x-p2.x) - (p3.y-p2.y)(p2.x-p1.x);
      |                                                        ^