Submission #103731

# Submission time Handle Problem Language Result Execution time Memory
103731 2019-04-02T10:01:44 Z ekrem Zalmoxis (BOI18_zalmoxis) C++
0 / 100
1000 ms 100392 KB
#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);
			break;
			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);
   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 98188 KB Time limit exceeded
2 Execution timed out 1081 ms 98152 KB Time limit exceeded
3 Execution timed out 1067 ms 98328 KB Time limit exceeded
4 Execution timed out 1079 ms 98240 KB Time limit exceeded
5 Execution timed out 1082 ms 98296 KB Time limit exceeded
6 Execution timed out 1081 ms 98268 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 98268 KB Time limit exceeded
2 Execution timed out 1047 ms 100392 KB Time limit exceeded
3 Incorrect 996 ms 100180 KB Unexpected end of file - int32 expected
4 Execution timed out 1075 ms 98424 KB Time limit exceeded
5 Execution timed out 1085 ms 98168 KB Time limit exceeded
6 Execution timed out 1073 ms 98296 KB Time limit exceeded
7 Execution timed out 1081 ms 98296 KB Time limit exceeded
8 Execution timed out 1082 ms 98296 KB Time limit exceeded
9 Incorrect 776 ms 80404 KB Unexpected end of file - int32 expected
10 Incorrect 296 ms 30444 KB Unexpected end of file - int32 expected
11 Incorrect 514 ms 50268 KB Unexpected end of file - int32 expected
12 Incorrect 2 ms 256 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