/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a;
int b;
long long int toplam=0;
scanf("%d",&a);
vector<int> c(a);
map<int,int> v;
for(int i=0;i<a;i++){
scanf("%d",&c[i]);
}
int eleman;
int sayac=a;
int kontrol=1;
while(kontrol){
kontrol=0;
for(int i=0;i<a;i++){
if(c[i]!=0){
eleman=i;
kontrol=1;
break;
}}
int ar=1;
for(int i=eleman+1;i<a;i++){
if((c[i]+ar)==c[eleman]){
sayac=sayac-1;
ar=ar+1;
c[i]=0;
}
}
c[eleman]=0;
}
printf("%d",sayac);
return 0;
}
Compilation message
baloni.cpp: In function 'int main()':
baloni.cpp:16:9: warning: unused variable 'b' [-Wunused-variable]
16 | int b;
| ^
baloni.cpp:18:19: warning: unused variable 'toplam' [-Wunused-variable]
18 | long long int toplam=0;
| ^~~~~~
baloni.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
19 | scanf("%d",&a);
| ~~~~~^~~~~~~~~
baloni.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d",&c[i]);
| ~~~~~^~~~~~~~~~~~
baloni.cpp:54:17: warning: 'eleman' may be used uninitialized in this function [-Wmaybe-uninitialized]
54 | c[eleman]=0;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
336 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
336 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
504 KB |
Output isn't correct |
4 |
Incorrect |
8 ms |
452 KB |
Output isn't correct |
5 |
Correct |
743 ms |
3576 KB |
Output is correct |
6 |
Correct |
1809 ms |
3664 KB |
Output is correct |
7 |
Correct |
1617 ms |
3284 KB |
Output is correct |
8 |
Correct |
1502 ms |
3152 KB |
Output is correct |
9 |
Correct |
1071 ms |
3408 KB |
Output is correct |
10 |
Correct |
1528 ms |
3528 KB |
Output is correct |