답안 #585662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585662 2022-06-29T07:53:37 Z 박상훈(#8384) MP3 Player (CEOI10_mp3player) C++17
10 / 100
1000 ms 1840 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
const int INF = 2e9+400;
bool p[100100], on[100100];
int a[100100], n, vmax, v2;

void _press(int &L, int &R, bool P){
    if (P){
        if (L>0) --L;
        if (R==0) {L = -1; return;}
        else if (R<vmax) --R;
    }
    else{
        if (R<vmax) ++R;
        if (L==vmax) {L = -1; return;}
        else if (L>0) ++L;
    }
}

void solve(int T){
    for (int i=1;i<=n;i++) on[i] = a[i]<=T;

    int L = v2, R = v2;
    for (int i=n;i;i--) if (on[i]){
        _press(L, R, p[i]);
        if (L==-1) return;
    }

    if (T==INF) printf("infinity\n");
    else printf("%d %d\n", T, R);
    exit(0);
}

int main(){
    scanf("%d %d %d", &n, &vmax, &v2);

    vector<int> V = {INF};
    int prv = 0;
    for (int i=0;i<n;i++){
        char op;
        int cur;
        scanf(" %c %d", &op, &cur);
        a[i] = cur - prv;
        prv = cur;

        on[i] = 1;
        if (op=='+') p[i] = 1;
        V.push_back(a[i]);
    }
    --n;

    sort(V.begin(), V.end(), greater<int>());
    for (auto &x:V) solve(x);
    printf("0\n");
    return 0;
}

Compilation message

mp3player.cpp: In function 'int main()':
mp3player.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d %d %d", &n, &vmax, &v2);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
mp3player.cpp:44:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         scanf(" %c %d", &op, &cur);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 26 ms 384 KB Output is correct
3 Incorrect 38 ms 380 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 5 ms 312 KB Output is correct
4 Correct 9 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 131 ms 900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 301 ms 932 KB Output is correct
2 Execution timed out 1088 ms 980 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 407 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 401 ms 1224 KB Output is correct
2 Execution timed out 1072 ms 1172 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1072 ms 1816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 1840 KB Time limit exceeded
2 Halted 0 ms 0 KB -