Submission #309990

#TimeUsernameProblemLanguageResultExecution timeMemory
309990juggernautRobots (IOI13_robots)C++14
0 / 100
1674 ms12708 KiB
#include"robots.h" #include<bits/stdc++.h> #define fr first #define sc second //#include"grader.c" using namespace std; int a,b,t,x[50005],y[50005]; pair<int,int>toy[1000005]; inline bool check(int m){ priority_queue<int>q; for(int i=0,tt=0;i<=a;i++){ for(;tt<t&&toy[tt].fr<x[i];tt++)q.push(toy[tt].sc); if(i!=a)for(int j=0;j<m&&(!q.empty());j++)q.pop(); } for(int i=b-1;i>=0&&(q.empty()||q.top()<y[i]);i--) for(int j=0;j<m&&(!q.empty());j++)q.pop(); return q.empty(); } int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){ a=A,b=B,t=T; x[a]=2e9+1; memcpy(x,X,sizeof(X)); memcpy(y,Y,sizeof(Y)); for(int i=0;i<t;i++)toy[i]={W[i],S[i]}; sort(x,x+a); sort(y,y+b); sort(toy,toy+t); int l=1,r=t; while(l<r){ int mid=(l+r)>>1; if(check(mid))r=mid; else l=mid+1; } if(!check(l))return -1; return l; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:22:25: warning: 'sizeof' on array function parameter 'X' will return size of 'int*' [-Wsizeof-array-argument]
   22 |      memcpy(x,X,sizeof(X));
      |                         ^
robots.cpp:19:35: note: declared here
   19 | int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){
      |                               ~~~~^~~
robots.cpp:22:17: warning: argument to 'sizeof' in 'void* memcpy(void*, const void*, size_t)' call is the same expression as the source; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
   22 |      memcpy(x,X,sizeof(X));
      |                 ^~~~~~~~~
robots.cpp:23:22: warning: 'sizeof' on array function parameter 'Y' will return size of 'int*' [-Wsizeof-array-argument]
   23 |   memcpy(y,Y,sizeof(Y));
      |                      ^
robots.cpp:19:43: note: declared here
   19 | int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){
      |                                       ~~~~^~~
robots.cpp:23:14: warning: argument to 'sizeof' in 'void* memcpy(void*, const void*, size_t)' call is the same expression as the source; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
   23 |   memcpy(y,Y,sizeof(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...