제출 #145641

#제출 시각아이디문제언어결과실행 시간메모리
145641peijar로봇 (IOI13_robots)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e6; struct Jouet { ll poids, taille, ind; bool operator<(Jouet other) const { return taille < other.taille or (taille == other.taille && (poids < other.poids or ( poids == other.poids && ind == other.ind))); } }; Jouet jouets[MAXN]; struct dispo_taille { int ind; bool operator<(dispo_taille other) const { return jouets[ind].poids < jouets[other.ind].poids or (jouets[ind].poids == jouets[other.ind].poids && ind < other.ind); } }; ll robots_fragiles[MAXN]; ll robots_petits[MAXN]; int smallest_fragile[MAXN]; int smallest_small[MAXN]; int N, A, B; bool can(int seconds) { priority_queue<dispo_taille> Q; int r = 0; for (int i(0); i < N; ++i) { int next_r = smallest_small[i]; if (next_r > r) { while (r < next_r) { int used(0); while (used < seconds && !Q.empty()) { ++used; Q.pop(); } ++r; } } r = next_r; Q.push({i}); } while (r++ < B) { int used(0); while (used < seconds && !Q.empty()) { ++used; Q.pop(); } } for (int i(A-1); i >= 0; --i) { int used(0); while (used < seconds && !Q.empty() && jouets[Q.top().ind].poids < robots_fragiles[i]) { ++used; Q.pop(); } } return Q.empty(); } int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> A >> B >> N; for (int i(0); i < A; ++i) cin >> robots_fragiles[i]; for (int i(0); i < B; ++i) cin >> robots_petits[i]; sort(robots_fragiles, robots_fragiles + A); sort(robots_petits, robots_petits + B); for (int i(0); i < N; ++i) { cin >> jouets[i].poids >> jouets[i].taille; jouets[i].ind = i; } sort(jouets, jouets + N); for (int i(0); i < N; ++i) { int l = 0, r = B-1; while (l < r) { int mid = (l+r)/2; if (jouets[i].taille < robots_petits[mid]) r = mid; else l = mid+1; } if (jouets[i].taille < robots_petits[l]) smallest_small[i] = l; else smallest_small[i] = B; } for (int i(0); i < N; ++i) if ((B == 0 || jouets[i].taille >= robots_petits[B-1]) && (A == 0 ||jouets[i].poids >= robots_fragiles[A-1])) { cout << -1 << endl; return 0; } int l(1), r(N); while (l < r) { int mid = (l+r)/2; if (can(mid)) r = mid; else l = mid +1; } cout << l << endl; }

컴파일 시 표준 에러 (stderr) 메시지

/tmp/ccsUCUku.o: In function `main':
robots.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccuA91eH.o:grader.c:(.text.startup+0x0): first defined here
/tmp/ccuA91eH.o: In function `main':
grader.c:(.text.startup+0x17e): undefined reference to `putaway'
collect2: error: ld returned 1 exit status