# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
159267 |
2019-10-21T20:56:00 Z |
AKaan37 |
Stove (JOI18_stove) |
C++17 |
|
396 ms |
196876 KB |
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
//~ #define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t,dp[5001][5001][2];
int cev;
string s;
vector<int> v;
inline int f(int sira,int kac,int al){
int cevv=inf;
if(kac>k)return inf;
//~ cout<<sira<<" "<<kac<<" "<<al<<endl;
if(sira>n)return 0;
if(~dp[sira][kac][al])return dp[sira][kac][al];
if(al==0){
cevv=min(cevv,f(sira+1,kac,1)+1);
cevv=min(cevv,f(sira+1,kac+1,0)+1);
}
if(al==1){
cevv=min(cevv,f(sira+1,kac,1)+a[sira]+1-(a[sira-1]+1));
cevv=min(cevv,f(sira+1,kac+1,0)+a[sira]+1-a[sira-1]-1);
}
return dp[sira][kac][al]=cevv;
}
main(void){
memset(dp,-1,sizeof(dp));
scanf("%d %d",&n,&k);
FOR{
scanf("%d",&a[i]);
}
printf("%d\n",f(1,1,0));
return 0;
}
Compilation message
stove.cpp:62:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(void){
^
stove.cpp: In function 'int main()':
stove.cpp:64:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&n,&k);
~~~~~^~~~~~~~~~~~~~~
stove.cpp:66:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i]);
~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
196132 KB |
Output is correct |
2 |
Correct |
186 ms |
196088 KB |
Output is correct |
3 |
Correct |
176 ms |
196088 KB |
Output is correct |
4 |
Correct |
164 ms |
196088 KB |
Output is correct |
5 |
Correct |
174 ms |
196084 KB |
Output is correct |
6 |
Correct |
185 ms |
196088 KB |
Output is correct |
7 |
Correct |
164 ms |
196088 KB |
Output is correct |
8 |
Correct |
165 ms |
196144 KB |
Output is correct |
9 |
Correct |
166 ms |
196160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
196132 KB |
Output is correct |
2 |
Correct |
186 ms |
196088 KB |
Output is correct |
3 |
Correct |
176 ms |
196088 KB |
Output is correct |
4 |
Correct |
164 ms |
196088 KB |
Output is correct |
5 |
Correct |
174 ms |
196084 KB |
Output is correct |
6 |
Correct |
185 ms |
196088 KB |
Output is correct |
7 |
Correct |
164 ms |
196088 KB |
Output is correct |
8 |
Correct |
165 ms |
196144 KB |
Output is correct |
9 |
Correct |
166 ms |
196160 KB |
Output is correct |
10 |
Correct |
167 ms |
196344 KB |
Output is correct |
11 |
Correct |
176 ms |
196376 KB |
Output is correct |
12 |
Correct |
272 ms |
196284 KB |
Output is correct |
13 |
Correct |
331 ms |
196380 KB |
Output is correct |
14 |
Correct |
369 ms |
196472 KB |
Output is correct |
15 |
Correct |
396 ms |
196352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
196132 KB |
Output is correct |
2 |
Correct |
186 ms |
196088 KB |
Output is correct |
3 |
Correct |
176 ms |
196088 KB |
Output is correct |
4 |
Correct |
164 ms |
196088 KB |
Output is correct |
5 |
Correct |
174 ms |
196084 KB |
Output is correct |
6 |
Correct |
185 ms |
196088 KB |
Output is correct |
7 |
Correct |
164 ms |
196088 KB |
Output is correct |
8 |
Correct |
165 ms |
196144 KB |
Output is correct |
9 |
Correct |
166 ms |
196160 KB |
Output is correct |
10 |
Correct |
167 ms |
196344 KB |
Output is correct |
11 |
Correct |
176 ms |
196376 KB |
Output is correct |
12 |
Correct |
272 ms |
196284 KB |
Output is correct |
13 |
Correct |
331 ms |
196380 KB |
Output is correct |
14 |
Correct |
369 ms |
196472 KB |
Output is correct |
15 |
Correct |
396 ms |
196352 KB |
Output is correct |
16 |
Incorrect |
207 ms |
196876 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |