# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145487 | charlies_moo | Rasvjeta (COCI17_rasvjeta) | C++98 | 3 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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-k;j<=s+k;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-k;j<=i+k;j++){
if(j>=1&&j<=n){
if(light[j]==0){
tot++;
}
}
}
}
if(tot>biggest){
biggest=tot;
seat=i;
}
}
for(int i=seat-k;i<=seat+k;i++){
if(i>=1&&i<=n){
light[i]=1;
}
}
}
else{
flag=1;
}
}
cout<<time;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |