Submission #74843915
Source Code Expand
#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); ++i)
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
int gcd(int a, int b){
if(b == 0) return a;
else return gcd(b, a%b);
}
struct Compare {
bool operator()(const pair<ll, int>& a, const pair<ll, int>& b) {
return a.first > b.first;
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
vector<double> l(n);
rep(i,n) cin >> l[i];
int ans = 0;
for(int bit = 0; bit < (1<<n);bit++){
double now = 0.5;
int tmp = 0;
rep(i,n){
double pre = now;
if(bit & (1<<i)){
now += l[i];
if(pre * now < 0) tmp++;
}else{
now -= l[i];
if(pre * now < 0) tmp++;
}
}
chmax(ans, tmp);
}
cout << ans << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Sneaking Glances |
| User | motomoto0001 |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 1205 Byte |
| Status | AC |
| Exec Time | 81 ms |
| Memory | 3868 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample_01.txt | AC | 1 ms | 3728 KiB |
| sample_02.txt | AC | 1 ms | 3716 KiB |
| sample_03.txt | AC | 72 ms | 3788 KiB |
| test_01.txt | AC | 1 ms | 3580 KiB |
| test_02.txt | AC | 1 ms | 3752 KiB |
| test_03.txt | AC | 1 ms | 3648 KiB |
| test_04.txt | AC | 1 ms | 3648 KiB |
| test_05.txt | AC | 78 ms | 3712 KiB |
| test_06.txt | AC | 38 ms | 3744 KiB |
| test_07.txt | AC | 77 ms | 3788 KiB |
| test_08.txt | AC | 1 ms | 3736 KiB |
| test_09.txt | AC | 78 ms | 3648 KiB |
| test_10.txt | AC | 1 ms | 3752 KiB |
| test_11.txt | AC | 78 ms | 3868 KiB |
| test_12.txt | AC | 78 ms | 3812 KiB |
| test_13.txt | AC | 1 ms | 3712 KiB |
| test_14.txt | AC | 1 ms | 3704 KiB |
| test_15.txt | AC | 81 ms | 3680 KiB |
| test_16.txt | AC | 38 ms | 3708 KiB |
| test_17.txt | AC | 79 ms | 3656 KiB |
| test_18.txt | AC | 76 ms | 3812 KiB |
| test_19.txt | AC | 1 ms | 3756 KiB |
| test_20.txt | AC | 1 ms | 3752 KiB |
| test_21.txt | AC | 1 ms | 3640 KiB |
| test_22.txt | AC | 1 ms | 3664 KiB |
| test_23.txt | AC | 1 ms | 3788 KiB |
| test_24.txt | AC | 1 ms | 3672 KiB |
| test_25.txt | AC | 1 ms | 3652 KiB |
| test_26.txt | AC | 1 ms | 3672 KiB |
| test_27.txt | AC | 73 ms | 3704 KiB |
| test_28.txt | AC | 73 ms | 3728 KiB |
| test_29.txt | AC | 70 ms | 3708 KiB |
| test_30.txt | AC | 70 ms | 3648 KiB |
| test_31.txt | AC | 71 ms | 3868 KiB |