| Task: | Key cutting |
| Sender: | Pynamic Drogramming |
| Submission time: | 2024-11-16 17:01:54 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | details |
| #2 | WRONG ANSWER | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | WRONG ANSWER | 0.00 s | details |
| #5 | WRONG ANSWER | 0.00 s | details |
| #6 | WRONG ANSWER | 0.00 s | details |
| #7 | WRONG ANSWER | 0.00 s | details |
| #8 | ACCEPTED | 0.00 s | details |
| #9 | WRONG ANSWER | 0.02 s | details |
| #10 | WRONG ANSWER | 0.02 s | details |
| #11 | WRONG ANSWER | 0.03 s | details |
| #12 | WRONG ANSWER | 0.03 s | details |
| #13 | WRONG ANSWER | 0.03 s | details |
| #14 | WRONG ANSWER | 0.04 s | details |
Compiler report
input/code.cpp: In function 'long long int interval(int, int)':
input/code.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i=0; i < borders.size()-1;i++){
| ~~^~~~~~~~~~~~~~~~~~Code
#include <bits/stdc++.h>
using namespace std;
#define imx 100001
long long arr[imx];
long long interval(int first,int last){
//If Interval length 1, we do a single cut
if(first==last-1) return 1;
//Find minimum in array and their positions
long long min = 10e9+1;
vector<int> borders;
for(int i=first; i < last; i++){
if(arr[i] < min){
vector<int> new_bord;
borders = new_bord;
min = arr[i];
}
if(arr[i] == min){
borders.push_back(i);
}
}
//for(int i=0; i < borders.size(); i++) cout << borders[i] << " ";
//cout << "\n";
int res = 0;
if(borders.size() > 0){
res = 1;
if(borders[0] > first) res += interval(first,borders[0]);
if(borders[borders.size()-1] < last-1) res += interval(borders[borders.size()-1]+1,last);
for(int i=0; i < borders.size()-1;i++){
res += interval(borders[i]+1,borders[i+1]);
}
}
return res;
}
int main()
{
int n;
cin >> n;
for(int i = 0; i<n; i++){
cin >> arr[i];
}
cout << interval(0,n) << "\n";
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 3 1 2 1 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 2 |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 1 0 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 1 9 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 100 0 0 0 1 1 0 0 0 0 1 1 1 0 1 1 ... |
| correct output |
|---|
| 25 |
| user output |
|---|
| 26 |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 100 2 1 2 1 2 0 0 0 1 1 2 2 1 2 2 ... |
| correct output |
|---|
| 41 |
| user output |
|---|
| 42 |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 100 36 5 10 37 94 59 20 31 64 2 58... |
| correct output |
|---|
| 99 |
| user output |
|---|
| 100 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 100 228768416 32415139 952687252 6... |
| correct output |
|---|
| 100 |
| user output |
|---|
| 100 |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 100000 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 ... |
| correct output |
|---|
| 24965 |
| user output |
|---|
| 24966 |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 100000 2 1 2 2 2 2 2 1 1 0 1 1 0 1 1 ... |
| correct output |
|---|
| 38968 |
| user output |
|---|
| 38969 |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 100000 4 4 5 4 4 5 0 2 2 1 4 4 1 0 5 ... |
| correct output |
|---|
| 59156 |
| user output |
|---|
| 59157 |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 100000 18 5 6 16 8 10 1 7 4 15 5 9 19... |
| correct output |
|---|
| 82598 |
| user output |
|---|
| 82599 |
Test 14
Verdict: WRONG ANSWER
| input |
|---|
| 100000 33 37 37 86 42 38 18 10 77 57 ... |
| correct output |
|---|
| 94897 |
| user output |
|---|
| 94898 |
