EkSulfur @ 2023-09-22 16:17:41
#include <iostream>
using namespace std;
int a[5000005];
void pl(int x, int y, int z); //加分函数
void qsort(int l, int r) {
int j = l, k = r;
int mid = a[(k + j) / 2];
do {
while (a[j] < mid)
j++;
while (a[k] > mid)
k--;
if (j <= k) {
swap(a[j], a[k]);
j++;
k--;
}
} while (j <= k);
if (l < k)
qsort(l, k);
if (j < r)
qsort(j, r);
}
int main() {
int n, m, min; //学生数,加分次数,最低分
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= m; i++) {
int x, y, z;
cin >> x >> y >> z;
pl(x, y, z);
}
for (int i = 1; i < n; i++) {
int ok = 1;
for (int j = 1; j < n; j++) {
if (a[j] > a[j + 1])
swap(a[j], a[j + 1]);
ok = 0;
}
if (ok == 1)
break;
}
cout << a[1];
return 0;
}
void pl(int x, int y, int z) {
for (int i = x; i <= y; i++)
a[i] += z;
}
by xaviertse @ 2023-09-26 17:36:29
重点不是快排,这题的标签是差分,别用暴力做,去看题解学一下
而且不需要排序,扫一遍用min找最小值就行了