Submission #97888

# Submission time Handle Problem Language Result Execution time Memory
97888 2019-02-19T10:32:59 Z AKaan37 Rasvjeta (COCI17_rasvjeta) C++17
25 / 50
3 ms 512 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#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(lo i=1;i<=n;i++)

const int inf = 1000000000;
const int mod = 1000000007;
const int KOK = 100000;
const int li = 100005;
const int LOG = 20;

lo n,m,cev,x,k,PS[li],cevap;
vector<int> v;
char c;
string s;

int main(){
	scanf("%lld %lld %lld",&n,&m,&k);
	PS[0]=0;
	for(lo i=1;i<=m;i++){
		scanf("%lld",&x);
		PS[max(x-k,1ll)]++;
		PS[min(x+k+1,n+1)]--;
	}
	FOR{
		PS[i]=PS[i-1]+PS[i];
	}
	FOR{
		lo cevv=PS[i];
		if(cevv<=0){cev++;}
		else{cevap+=cev/(k*2)+(cev%(k*2)==0?0:1);cev=0;}
	}
	cevap+=cev/(k*2)+(cev%(k*2)==0?0:1);
	printf("%lld",cevap);
	return 0;
}

Compilation message

rasjveta.cpp: In function 'int main()':
rasjveta.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
rasjveta.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&x);
   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 472 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Runtime error 3 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)