Submission #931478

#TimeUsernameProblemLanguageResultExecution timeMemory
931478OAleksaRobots (IOI13_robots)C++14
76 / 100
3068 ms17492 KiB
#include <bits/stdc++.h>
#include"robots.h"
using namespace std;
#define f first
#define s second

int putaway(int A, int B, int t, int x[], int y[], int w[], int s[]) {
  int n = A, m = B;
  sort(x, x + n);
  sort(y, y + m);
  vector<int> vis(t);
  for (int i = 0;i < t;i++) {
  	if (w[i] >= x[n - 1] && s[i] >= y[m - 1]) 
  		return -1;
  }
 	int ans = 0;
 	while (1) {
 		int g = 1;
 		for (int i = 0;i < t;i++)
 			g &= vis[i];
 		if (g)
 			break;
 		for (int i = 0;i < n;i++) {
 			int d = -1;
 			for (int j = 0;j < t;j++) {
 				if (vis[j])
 					continue;
 				if (w[j] < x[i]) {
 					if (d == -1)
 						d = j;
 					else if (s[j] > s[d])
 						d = j;
 				}
 			}
 			if (d != -1)
 				vis[d] = 1;
 		}
 		for (int i = 0;i < m;i++) {
 			int d = -1;
 			for (int j = 0;j < t;j++) {
 				if (vis[j])
 					continue;
 				if (s[j] < y[i]) {
 					if (d == -1)
 						d = j;
 					else if (w[j] > w[d])
 						d = j;
 				}
 			}
 			if (d != -1)
 				vis[d] = 1;
 		}
 		++ans;
 	}
 	return ans;
}                                                                                                                                                                                                                                                   

// signed main() {
  // ios::sync_with_stdio(false);
  // cin.tie(0);
  // cout.tie(0);
  // int tt = 1;
  // //cin >> tt;
  // while (tt--) {
  	// int a, b, t;
  	// cin >> a >> b >> t;
  	// int x[a], y[b], w[t], s[t];
  	// for (int i = 0;i < a;i++)
  		// cin >> x[i];
  	// for (int i = 0;i < b;i++)
  		// cin >> y[i];
  	// for (int i = 0;i < t;i++)
  		// cin >> w[i];
  	// for (int i = 0;i < t;i++)
  		// cin >> s[i];
  	// cout << putaway(a, b, t, x, y, w, s) << '\n';
  // }
  // return 0;
// }
#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...