Submission #1011230

# Submission time Handle Problem Language Result Execution time Memory
1011230 2024-06-30T07:02:37 Z MilosMilutinovic MP3 Player (CEOI10_mp3player) C++14
20 / 100
1000 ms 2896 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, trg;
  cin >> n >> m >> trg;
  vector<char> op(n);
  vector<int> val(n);
  for (int i = 0; i < n; i++) {
    cin >> op[i] >> val[i];
  }
  const int inf = (int) 2.000001e9;
  vector<int> qt(1, -1);
  qt.push_back(val[0]);
  qt.push_back(inf);
  for (int i = 1; i < n; i++) {
    qt.push_back(val[i] - val[i - 1]);
  }
  vector<int> new_qt;
  for (int t : qt) {
    new_qt.push_back(t);
    new_qt.push_back(t - 1);
  }
  qt = new_qt;
  sort(qt.rbegin(), qt.rend());
  for (int t : qt) {
    for (int v1 = m; v1 >= 0; v1--) {
      int v2 = v1;
      for (int i = 1; i < n; i++) {
        int d = val[i] - val[i - 1];
        if (d <= t) {
          if (op[i] == '+') {
            v2 = min(v2 + 1, m);
          } else {
            v2 = max(v2 - 1, 0);
          }
        }
      }
      if (v2 == trg) {
        if (t == inf) {
          cout << "infinity" << '\n'; 
        } else {
          cout << t << " " << v1 << '\n';
        }
        return 0;
      }
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 544 KB Output is correct
2 Execution timed out 1057 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 899 ms 492 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 831 ms 496 KB Output is correct
4 Correct 15 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 980 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1025 ms 980 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1039 ms 1236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 1620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 2896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1014 ms 2896 KB Time limit exceeded
2 Halted 0 ms 0 KB -