Submission #29879

#TimeUsernameProblemLanguageResultExecution timeMemory
29879NikeforRobots (IOI13_robots)C++98
14 / 100
253 ms17680 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; int XG[50001], YG[50001], WG[1000001], SG[1000001], AG, BG, TG; bool suit(int t, bool type, int r) { /* true if weak, false if small */ if(type and WG[t] >= XG[r]) return false; if(!type and SG[t] >= YG[r]) return false; return true; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { AG=A, BG=B, TG=T; for(int i=0; i<T; i++) { WG[i] = W[i]; SG[i] = S[i]; } for(int i=0; i<A; i++) XG[i] = X[i]; for(int i=0; i<B; i++) YG[i] = Y[i]; if(T==2 and (A+B)==2) { if(A==2) { if( (suit(0, true,0) and suit(1, true, 1) ) or ( suit(0,true,1) and suit(1,true,0) ) ) return 1; else if( (suit(0, true,0) and suit(1, true, 0) ) or ( suit(0,true,1) and suit(1,true,1) ) ) return 2; return -1; } if(B==2) { if( (suit(0, false,0) and suit(1, false, 1) ) or ( suit(0,false,1) and suit(1,false,0) ) ) return 1; else if( (suit(0, false,0) and suit(1, false, 0) ) or ( suit(0,false,1) and suit(1,false,1) ) ) return 2; return -1; } if( (suit(0, false,0) and suit(1, true, 0) ) or ( suit(0,true,0) and suit(1,false,0) ) ) return 1; else if( (suit(0, false,0) and suit(1, false, 0) ) or ( suit(0,true,0) and suit(1,true,0) ) ) return 2; return -1; } if(B==0) { vector<int> vec; for(int i=0; i<T; i++) vec.push_back(W[i]); sort(vec.begin(), vec.end()); int t = 1; vector<int> robot; for(int i=0; i<A; i++) robot.push_back(X[i]); sort(robot.begin(), robot.end()); int rob = A-1; int use[A+1]; // printf("robot cap = %d\n", robot[rob]); for(int i=0; i<A; i++) use[i] = 0; for(int i=T-1; i>-1 and rob>-1; i--) { // printf("robot cap = %d toy = %d\n", robot[rob], vec[i]); if(vec[i]>=robot[rob]) return -1; if(use[rob]<t) { use[rob]++; /*printf("heb1\n");*/ continue;} if(!rob) {t++; use[rob]++; /*printf("heb2\n"); */continue;} if(vec[i]<robot[rob-1]) { rob--; // printf("heb3\n"); use[rob]++; continue; } use[rob]++; // printf("heb4\n"); t++; } return t; } return 42; }
#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...