답안 #117731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
117731 2019-06-17T07:14:30 Z 김세빈(#2878) Segway (COI19_segway) C++14
100 / 100
905 ms 1556 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;

priority_queue <pii, vector <pii>, greater <pii>> Q;
vector <int> V;
int A[20202], B[20202], C[20202];
int D[20209], X[20202], F[20202];
int T[333], S[333];
int n, m;

int main()
{
	int i, t, x;

	scanf("%d", &n);

	for(i=0; i<n; i++){
		scanf("%d%d%d", A + i, B + i, C + i);
		Q.push(pii(0, i)); D[i] = 0; X[i] = 0;
	}

	scanf("%d", &m);

	for(i=0; i<m; i++){
		scanf("%d", &x);
		T[x] = 1;
	}

	for(; !Q.empty(); ){
		V.clear(); t = Q.top().first;
		for(; !Q.empty() && Q.top().first == t; Q.pop()){
			V.push_back(Q.top().second);
		}

		for(int &p: V){
			if(D[p] == 300){
				F[p] = t;
				continue;
			}
			if(T[D[p]] && !X[p]) X[p] = S[D[p]] % 20;

			if(X[p]){
				X[p] --;
				Q.push(pii(t + 1, p));
			}
			else if(D[p] < 100) Q.push(pii(t + A[p], p));
			else if(D[p] < 200) Q.push(pii(t + B[p], p));
			else Q.push(pii(t + C[p], p));
		}

		for(int &p: V){
			S[D[p]] ++;
			D[p] ++;
		}
	}

	for(i=0; i<n; i++){
		printf("%d\n", F[i]);
	}

	printf("\n");

	return 0;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
segway.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", A + i, B + i, C + i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
  ~~~~~^~~~~~~~~~
segway.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 29 ms 512 KB Output is correct
4 Correct 115 ms 512 KB Output is correct
5 Correct 905 ms 1556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 412 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 9 ms 384 KB Output is correct
10 Correct 11 ms 384 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 29 ms 512 KB Output is correct
4 Correct 115 ms 512 KB Output is correct
5 Correct 905 ms 1556 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 412 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 8 ms 384 KB Output is correct
14 Correct 9 ms 384 KB Output is correct
15 Correct 11 ms 384 KB Output is correct
16 Correct 9 ms 384 KB Output is correct
17 Correct 36 ms 384 KB Output is correct
18 Correct 61 ms 504 KB Output is correct
19 Correct 328 ms 888 KB Output is correct
20 Correct 472 ms 1016 KB Output is correct
21 Correct 559 ms 1244 KB Output is correct
22 Correct 693 ms 1524 KB Output is correct
23 Correct 599 ms 1396 KB Output is correct