Submission #116861

#TimeUsernameProblemLanguageResultExecution timeMemory
116861HungAnhGoldIBO2020San (COCI17_san)C++11
Compilation error
0 ms0 KiB
#include<iostream> #include<algorithm> #define int long long using namespace std; const int N=42; const int inf=1e18; pair<int,int> ar[N]; vector<int> val[N],val1[N]; signed main(){ int n,i,j,k,l,num,pos; int ans=0; cin>>n>>num; for(i=1;i<=n;i++){ cin>>ar[i].first>>ar[i].second; } if(n==1){ if(ar[1].second>=num){ cout<<1; } else{ cout<<0; } } for(i=1;i<(1ll<<(n/2));i++){ k=0,l=0; for(j=1;j<=n/2;j++){ if(((1<<(j-1))&i)){ if(ar[j].first<l){ break; } k+=ar[j].second; l=ar[j].first; pos=j; } if(j==n/2){ val[pos].push_back(k); //cout<<pos<<" "<<k<<endl; if(k>=num){ ans++; } } } } for(i=1;i<(1ll<<(n-n/2));i++){ k=0,l=inf; for(j=n;j>n/2;j--){ if(((1<<(j-n/2-1))&i)){ if(ar[j].first>l){ break; } k+=ar[j].second; l=ar[j].first; pos=j; } if(j==n/2+1){ val1[pos].push_back(k); //cout<<pos<<" "<<k<<endl; if(k>=num){ ans++; } } } } for(i=1;i<=n/2;i++){ sort(val[i].begin(),val[i].end()); } for(i=n/2+1;i<=n;i++){ sort(val1[i].begin(),val1[i].end()); } for(i=1;i<=n/2;i++){ for(j=n/2+1;j<=n;j++){ if(ar[i].first<=ar[j].first){ for(k=0;k<val[i].size();k++){ l=lower_bound(val1[j].begin(),val1[j].end(),num-val[i][k])-val1[j].begin(); ans+=val1[j].size()-l; } } } } cout<<ans; }

Compilation message (stderr)

san.cpp:8:1: error: 'vector' does not name a type; did you mean 'perror'?
 vector<int> val[N],val1[N];
 ^~~~~~
 perror
san.cpp: In function 'int main()':
san.cpp:36:5: error: 'val' was not declared in this scope
     val[pos].push_back(k);
     ^~~
san.cpp:56:5: error: 'val1' was not declared in this scope
     val1[pos].push_back(k);
     ^~~~
san.cpp:65:8: error: 'val' was not declared in this scope
   sort(val[i].begin(),val[i].end());
        ^~~
san.cpp:68:8: error: 'val1' was not declared in this scope
   sort(val1[i].begin(),val1[i].end());
        ^~~~
san.cpp:73:15: error: 'val' was not declared in this scope
     for(k=0;k<val[i].size();k++){
               ^~~
san.cpp:74:20: error: 'val1' was not declared in this scope
      l=lower_bound(val1[j].begin(),val1[j].end(),num-val[i][k])-val1[j].begin();
                    ^~~~