# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
42325 | 2018-02-26T06:04:22 Z | milmillin | Deda (COCI17_deda) | C++14 | 919 ms | 38512 KB |
#include <cstdio> #include <algorithm> #include <set> #include <map> #include <vector> using namespace std; set<int> bit[200100]; map<int,int> comp; struct query { char x; int a,b; }; int mxx; void update (int idx,int val) { while (idx<mxx) { bit[idx].insert(val); //printf("++ %d\n",idx); //for (auto &i:bit[idx]) { //printf("%d ",i); //} //printf("\n"); idx+=(idx&-idx); } } int get (int idx,int val) { int ans=2e9; while (idx) { auto it = bit[idx].lower_bound(val); //printf("## %d\n",idx); //for (auto &i:bit[idx]) { //printf("%d ",i); //} //printf("\n"); if (it!=bit[idx].end()) { //printf("*** %d\n",*it); ans = min(ans,*it); } idx-=(idx&-idx); } return ans; } int main () { int n,q; scanf("%d%d",&n,&q); mxx=n+1000; char x; int a,b; vector<query> qq; for (int i=0;i<q;i++) { scanf(" %c%d%d",&x,&a,&b); comp[a]; qq.push_back(query{x,a,b}); } int cnt=1; for (auto &i:comp) { i.second = cnt++; } for (auto &i:qq) { i.a=comp[i.a]; //printf("-- %d %d\n",i.a,i.b); if (i.x=='M') { update(i.a,i.b); } else { int tmp = get(i.a,i.b); printf("%d\n",(tmp==2e9)?-1:tmp); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9720 KB | Output is correct |
2 | Correct | 9 ms | 9824 KB | Output is correct |
3 | Incorrect | 14 ms | 10132 KB | Output isn't correct |
4 | Correct | 437 ms | 20984 KB | Output is correct |
5 | Incorrect | 713 ms | 31208 KB | Output isn't correct |
6 | Incorrect | 819 ms | 35356 KB | Output isn't correct |
7 | Correct | 919 ms | 38512 KB | Output is correct |