# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
42326 | 2018-02-26T06:05:50 Z | milmillin | Deda (COCI17_deda) | C++14 | 1000 ms | 38836 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+10000; 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 | 10 ms | 9720 KB | Output is correct |
2 | Correct | 9 ms | 9824 KB | Output is correct |
3 | Correct | 15 ms | 10388 KB | Output is correct |
4 | Correct | 429 ms | 21164 KB | Output is correct |
5 | Incorrect | 764 ms | 33280 KB | Output isn't correct |
6 | Incorrect | 938 ms | 37480 KB | Output isn't correct |
7 | Execution timed out | 1024 ms | 38836 KB | Time limit exceeded |