제출 #1369978

#제출 시각아이디문제언어결과실행 시간메모리
1369978codexistentBouquet (EGOI24_bouquet)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
using namespace std;
#define int long long
const int N=2e5+5;

int n,ft[N],f[N],z=1;
vector<int>a[N];

void upd(int i,int v){ while(i<=n)ft[i]=max(ft[i],v),i+=(i&-i);}
int qry(int i){ return (i>0)?max(ft[i],qry(i-(i&-i))):0ll; }

signed main(){
    cin>>n;
    for(int i=1,l,r;i<=n;i++){
        for(int ai:a[i])upd(ai,f[ai]);

        cin>>l>>r,f[i]=1+qry(max(0ll,i-l-1));
        z=max(z,f[i]);

        for(int ai:a[i])upd(ai,f[ai]);
        if(i+r+1<=n)a[i+r+1].push_back(i);
    }
    cout<<z<<endl;
}

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

Main.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int>a[N];
      | ^~~~~~
Main.cpp: In function 'int main()':
Main.cpp:15:20: error: 'a' was not declared in this scope; did you mean 'ai'?
   15 |         for(int ai:a[i])upd(ai,f[ai]);
      |                    ^
      |                    ai
Main.cpp:20:20: error: 'a' was not declared in this scope; did you mean 'ai'?
   20 |         for(int ai:a[i])upd(ai,f[ai]);
      |                    ^
      |                    ai
Main.cpp:21:21: error: 'a' was not declared in this scope
   21 |         if(i+r+1<=n)a[i+r+1].push_back(i);
      |                     ^