Submission #7982

#TimeUsernameProblemLanguageResultExecution timeMemory
7982paulsohn앱 (KOI13_app)C++98
3.15 / 21
1000 ms1100 KiB
#include <stdio.h> int N, M, c[100] = { 0 }, m[100] = { 0 }, deque[100] = { 0 }, front = 0, rear = 0, uber[100] = { 0 }; bool seg[100][100] = { 0 }; void push(int elm){ deque[rear++] = elm; return; } int pop(){ ++front; return deque[front - 1]; } int cost(int remmem){ int first, used, unused, move=0; bool check[100] = { 0 }; if (remmem <= 0) return 0; if (front == rear) return 10001; first = pop(); for (int i = 0; i < N; ++i){ if (seg[first][i]){ check[i] = 1; seg[first][i] = 0; --uber[i]; if (uber[i] == 0){ push(i); ++move; } } } unused = cost(remmem); used = c[first]+cost(remmem - m[first]); --front; rear -= move; for (int i = 1; i<N; ++i){ if (check[i]){ seg[first][i] = 1; ++uber[i]; } } if (used > unused) return unused; return used; } int main(){ scanf("%d %d", &N, &M); for (int i = 0; i < N; ++i){ scanf("%d", &m[i]); } for (int i = 0; i < N; ++i){ scanf("%d", &c[i]); for (int j = 0; j < i; ++j){ if ((c[i] <= c[j]) && (m[i] >= m[j])){ seg[i][j] = 1; ++uber[j]; } else if ((c[i] >= c[j]) && (m[i] <= m[j])){ seg[j][i] = 1; ++uber[i]; } } } for (int i = 0; i < N; ++i){ if (uber[i] == 0) push(i); } printf("%d\n", cost(M)); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...