mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-24 04:28:47 +00:00
32 lines
428 B
C++
32 lines
428 B
C++
|
#include <iostream>
|
||
|
#include <set>
|
||
|
|
||
|
using std::cin;
|
||
|
using std::cout;
|
||
|
const char endl = '\n';
|
||
|
|
||
|
int n, m;
|
||
|
std::set<int> set;
|
||
|
|
||
|
int main() {
|
||
|
cin >> n >> m;
|
||
|
|
||
|
set.insert(0);
|
||
|
set.insert(n);
|
||
|
|
||
|
while (m--) {
|
||
|
int k;
|
||
|
|
||
|
cin >> k;
|
||
|
|
||
|
set.insert(k);
|
||
|
|
||
|
int prev = *--set.lower_bound(k),
|
||
|
next = *set.upper_bound(k);
|
||
|
|
||
|
cout << (k - prev) * (next - k) << endl;
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|