Submission #436171

#TimeUsernameProblemLanguageResultExecution timeMemory
436171cpp219Ice Hockey World Championship (CEOI15_bobek)C++14
20 / 100
86 ms10564 KiB
#pragma GCC optimization O2 #pragma GCC optimization "unroll-loop" #pragma target ("avx2") #include <bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 40 + 9; const ll inf = 1e9 + 7; vector<ll> v1,v2; ll n,k,now,ans,a[N]; void f1(ll i){ if (i > n/2){ if (now <= k) v1.push_back(now); return; } f1(i + 1); now += a[i]; f1(i + 1); now -= a[i]; } void f2(ll i){ if (i > n){ if (now <= k) v2.push_back(now); return; } f2(i + 1); now += a[i]; f2(i + 1); now -= a[i]; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "test" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n>>k; for (ll i = 1;i <= n;i++) cin>>a[i]; f1(1); now = 0; f2(n/2 + 1); //for (auto i : v2) cout<<i<<" "; return 0; sort(v2.begin(),v2.end()); for (auto i : v1){ ll inc = prev(upper_bound(v2.begin(),v2.end(),k - i)) - v2.begin() + 1; //cout<<inc<<"x\n"; ans += inc; } cout<<ans; }

Compilation message (stderr)

bobek.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization O2
      | 
bobek.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
bobek.cpp:3: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    3 | #pragma target ("avx2")
      | 
bobek.cpp: In function 'int main()':
bobek.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...