# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
332289 |
2020-12-01T23:46:38 Z |
alien_lover |
Hacker (BOI15_hac) |
C++14 |
|
1 ms |
364 KB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
const int PRIME = 1e9 + 7;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("TASK_NAME.in", "r", stdin);
// freopen("TASK_NAME.out", "w", stdout);
// Use scanf printf
int n;
cin >> n;
vector<int> scores(n);
int maxNumHacked = (n + 1) / 2;
int totSum = 0;
for(int i = 0; i < n; i++){
cin >> scores[i];
totSum += scores[i];
}
int windowScore = 0;
for(int i = 0; i < maxNumHacked; i++){
windowScore += scores[i];
}
int minDiff = windowScore * 2 - totSum;
int bestScore = windowScore;
for(int i = 0; i < n; i++){
// compare window starting at i
// subtract element at i, add next element
if(abs(windowScore * 2 - totSum) < minDiff){
minDiff = windowScore * 2 - totSum;
bestScore = windowScore;
}
// maxScore = min(minDiff, windowScore);
windowScore -= scores[i];
windowScore += scores[(i + maxNumHacked) % n];
}
cout << bestScore << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |