AC了但是样例输出1是什么鬼哇

P2367 语文成绩

MikanseIA @ 2024-12-24 12:37:30

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n, p, ans = 100;
  cin >> n >> p;
  int score[n + 1] = {};
  int diff[n + 1] = {};
  for(int i = 1; i <= n; i++) cin >> score[i];
  for(int i = 1; i <= n; i++) diff[i] = score[i] - score[i - 1];
  while(p--) {
    int x, y, z;
    cin >> x >> y >> z;
    diff[x] += z;
    diff[y + 1] -= z;
  }
  for(int i = 1; i <= n; i++) score[i] = diff[i] + score[i - 1];
  for(int i = 1; i <= n; i++) ans = min(ans, score[i]);
  cout << ans;
}

by lisitong01 @ 2024-12-24 13:06:53

我在DEVc++上运行了你的代码,输出正确啊!


by MikanseIA @ 2024-12-24 14:14:13

@lisitong01不知道欸,那应该就是我vsc抽风了吧


|