#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;
typedef long long ll;
typedef pair < int , int > ii;
int n, k, m, a[N], b[N];
ii ans;
set < ii > s, q;
set < ii > :: iterator it;
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d %d",&n ,&k);
for(int i = 1; i <= n; i++){
scanf("%d",a + i);
q.insert(mp(a[i], i));
s.insert(mp(i, a[i]));
}
while(!q.empty()){
int kac = q.begin()->st;
if(kac == 30)
break;
int ind = q.begin()->nd;
// cout << kac << " " << ind << endl;
it = s.find(mp(ind, kac));
it++;
if(it != s.end() and it->nd == kac){
int ind2 = it->st;
// cout << "BULDUM " << ind << " " << ind2 << endl;
s.erase(mp(ind, kac));
s.erase(mp(ind2, kac));
s.insert(mp(ind2, kac + 1));
q.erase(mp(kac, ind));
q.erase(mp(kac, ind2));
q.insert(mp(kac + 1, ind2));
} else{
// cout << ind << " den sonra " << kac << " ekle" << endl;
ans = mp(ind, kac);
s.erase(mp(ind, kac));
s.insert(mp(ind, kac + 1));
q.erase(mp(kac, ind));
q.insert(mp(kac + 1, ind));
}
}
for(int i = 1; i <= n; i++){
printf("%d ", a[i]);
if(i == ans.st)
printf("%d ", ans.nd);
}
return 0;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&n ,&k);
~~~~~^~~~~~~~~~~~~~~~
zalmoxis.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",a + i);
~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1088 ms |
100324 KB |
Time limit exceeded |
2 |
Execution timed out |
1046 ms |
100352 KB |
Time limit exceeded |
3 |
Execution timed out |
1081 ms |
100292 KB |
Time limit exceeded |
4 |
Execution timed out |
1082 ms |
100472 KB |
Time limit exceeded |
5 |
Execution timed out |
1077 ms |
100420 KB |
Time limit exceeded |
6 |
Execution timed out |
1052 ms |
100156 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1065 ms |
100252 KB |
Time limit exceeded |
2 |
Execution timed out |
1071 ms |
100168 KB |
Time limit exceeded |
3 |
Execution timed out |
1083 ms |
100108 KB |
Time limit exceeded |
4 |
Execution timed out |
1074 ms |
100228 KB |
Time limit exceeded |
5 |
Execution timed out |
1079 ms |
100344 KB |
Time limit exceeded |
6 |
Execution timed out |
1091 ms |
100376 KB |
Time limit exceeded |
7 |
Execution timed out |
1079 ms |
100472 KB |
Time limit exceeded |
8 |
Execution timed out |
1081 ms |
100600 KB |
Time limit exceeded |
9 |
Execution timed out |
1075 ms |
80480 KB |
Time limit exceeded |
10 |
Incorrect |
714 ms |
30988 KB |
Unexpected end of file - int32 expected |
11 |
Execution timed out |
1083 ms |
50404 KB |
Time limit exceeded |
12 |
Incorrect |
2 ms |
384 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
2 ms |
384 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
2 ms |
384 KB |
Unexpected end of file - int32 expected |