Submission #863912

#TimeUsernameProblemLanguageResultExecution timeMemory
863912RifalCigle (COI21_cigle)C++14
0 / 100
1012 ms348 KiB
#include <bits/stdc++.h> #include <fstream> //#define endl '\n' #define mod 1000000007 #define INF 900000000 using namespace std; //ofstream fout("intel.out"); //ifstream fin("intel.in"); int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); int n; cin >> n; int arr[n]; for(int i = 0; i < n; i++) { cin >> arr[i]; } int sol = 0; for(int i = 0; i < (1<<n); i++) { vector<int> v, v2; long long sum = 0; int ans = 0; for(int j = 0; j < n; j++) { if((i&(1<<j)) > 0) { v.push_back(arr[j]); sum += arr[j]; if(!v2.empty() && v2.size() != 1 && j != n && (i&(1<<(j+1)) > 0 )) { if(sum == v2.back()) ans++; if(sum >= v2.back()) { sum -= v2.back(); v2.pop_back(); } } } else { v2 = v; sum = arr[j]; if(!v2.empty() && v2.size() != 1 && j != n && (i&(1<<(j+1)) > 0)) { if(sum == v2.back()) ans++; if(sum >= v2.back()) { sum -= v2.back(); v2.pop_back(); } } v.clear(); v.push_back(arr[j]); } } sol = max(sol,ans); } cout << sol; return 0; }

Compilation message (stderr)

cigle.cpp: In function 'int main()':
cigle.cpp:25:77: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   25 |                 if(!v2.empty() && v2.size() != 1 && j != n && (i&(1<<(j+1)) > 0 )) {
      |                                                                  ~~~~~~~~~~~^~~
cigle.cpp:36:77: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   36 |                 if(!v2.empty() && v2.size() != 1 && j != n && (i&(1<<(j+1)) > 0)) {
      |                                                                  ~~~~~~~~~~~^~~
#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...