結果
| 問題 |
No.618 labo-index
|
| コンテスト | |
| ユーザー |
tails
|
| 提出日時 | 2017-12-18 09:56:17 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 423 ms / 6,000 ms |
| コード長 | 938 bytes |
| コンパイル時間 | 615 ms |
| コンパイル使用メモリ | 28,928 KB |
| 実行使用メモリ | 20,736 KB |
| 最終ジャッジ日時 | 2024-12-15 23:21:46 |
| 合計ジャッジ時間 | 6,036 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
コンパイルメッセージ
main.c:40:1: warning: return type defaults to 'int' [-Wimplicit-int]
40 | main(){
| ^~~~
main.c: In function 'main':
main.c:43:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
43 | scanf("%d",&x);
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | typedef long long ll;
main.c:43:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
43 | scanf("%d",&x);
| ^~~~~
main.c:43:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:70:25: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
70 | printf("%d\n",l);
| ^~~~~~
main.c:70:25: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:70:25: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:70:25: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
typedef long long ll;
typedef struct {
int c,l,r;
} Node;
Node ns[6000000];
int nn;
void add(int i,ll v,ll l,ll r,int inc){
Node*p=ns+i;
p->c+=inc;
if(l<r-1){
ll c=(l+r)/2;
if(v<c){
if(!p->l){
p->l=++nn;
}
add(p->l,v,l,c,inc);
}else{
if(!p->r){
p->r=++nn;
}
add(p->r,v,c,r,inc);
}
}
}
int count(int i,ll v,ll l,ll r){
Node*p=ns+i;
ll c=(l+r)/2;
return v<c?
(p->l?count(p->l,v,l,c):0)+(p->r?ns[p->r].c:0):
(p->r?count(p->r,v,c,r):0);
}
ll a[100010];
int n;
main(){
ll offset=1ll<<49;
int t,x;
scanf("%d",&x);
for(;~scanf("%d%d",&t,&x);){
if(t==1){
ll y=x+offset;
a[++n]=y;
add(0,y,0,1ll<<50,1);
}
if(t==2){
ll y=a[x];
add(0,y,0,1ll<<50,-1);
}
if(t==3){
offset-=x;
}
{
int l=0;
int r=ns[0].c+1;
while(l<r-1){
int c=(l+r)/2;
if(count(0,c+offset-1,0,1ll<<50)>=c){
l=c;
}else{
r=c;
}
}
printf("%d\n",l);
}
}
}
tails