제출 #59395

#제출 시각아이디문제언어결과실행 시간메모리
59395spencercompton로봇 (IOI13_robots)C++17
100 / 100
1479 ms42476 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { sort(x,x+a); sort(y,y+b); int zz = 0; map<int, int> m; set<int> ss; int inf = 2000000001; for(int i = b-1; i>=0; i--){ m[y[i]] = i; ss.insert(y[i]); } m[inf] = b; ss.insert(inf); vector<pair<int, int> > li; for(int i = 0; i<t; i++){ li.push_back(make_pair(w[i],s[i])); } sort(li.begin(),li.end()); int above[t]; for(int i = 0; i<t; i++){ auto it = ss.upper_bound(li[i].second); above[i] = m[*it]; //mit } int low = 1; int high = t+1; while(low<high){ int mid = (low+high)/2; priority_queue<int> pq; int point = 0; for(int i = 0; i<a; i++){ while(point<t && li[point].first<x[i]){ pq.push(above[point++]); } for(int j = 0; j<mid && pq.size()>0; j++){ pq.pop(); } } while(point<t){ pq.push(above[point++]); } int cnt[b+1]; for(int i = 0; i<=b; i++){ cnt[i] = 0; } while(pq.size()>0){ cnt[pq.top()]++; pq.pop(); } long long maxi = 0LL; bool ok = true; int sum = 0; for(int i = b; i>=0 && ok; i--){ sum += cnt[i]; ok &= sum <= maxi; maxi += mid; } if(ok){ high = mid; } else{ low = mid+1; } } return (low<=t?low:-1); }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:7:9: warning: unused variable 'zz' [-Wunused-variable]
     int zz = 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...