# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145491 | 2019-08-20T08:57:20 Z | charlies_moo | Rasvjeta (COCI17_rasvjeta) | C++ | 3 ms | 396 KB |
#include <iostream> using namespace std; int main(){ int n,l,k; cin>>n>>k>>l; int light[n+1]; int s; for(int i=1;i<=n;i++){ light[i]=0; } for(int i=0;i<k;i++){ cin>>s; for(int j=s-l;j<=s+l;j++){ if(j>=1&&j<=n){ light[j]=1; } } } //for(int i=1;i<=n;i++){ //cout<<light[i]<<" "; //} int flag=0; int time=0; while(flag==0){ int flag2=0; int biggest=0; int seat; for(int i=1;i<=n;i++){ if(light[i]==0){ flag2=1; } } if(flag2==1){ time++; for(int i=1;i<=n;i++){ int tot=0; if(light[i]==0){ for(int j=i-l;j<=i+l;j++){ if(j>=1&&j<=n){ if(light[j]==0){ tot++; } } } } if(tot>biggest){ biggest=tot; seat=i; } } for(int i=seat-l;i<=seat+l;i++){ if(i>=1&&i<=n){ light[i]=1; } } } else{ flag=1; } } cout<<time; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 3 ms | 396 KB | Output is correct |