Submission #5021296
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned ui; typedef unsigned long long ul; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef pair<bool, bool> pbb; typedef vector<int> vi; #define pb push_back #define fi first #define se second #define mid ((l + r) >> 1) #define ls (i << 1) #define rs (i << 1 | 1) #define enum(i, j, k) for(int i = j; i <= (k); i ++) #define open(i, j, k) for(int i = j; i < (k); i ++) #define dec(i, j, k) for(int i = j; i >= (k); i --) #define ae(x) for(node *p = h[x]; p; p = p->nxt) #define fill(x, k) memset(x, k, sizeof x) #define copy(x, y) memcpy(x, y, sizeof x) #define fio(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout); template <class T> bool chkmin(T &x, T y) { return y < x ? (x = y , true) : false; } template <class T> bool chkmax(T &x, T y) { return y > x ? (x = y , true) : false; } void __init() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout << fixed << setprecision(16); srand(time(0) ^ ui(ul(new char))); } /* default code ends here */ const int maxn = 2e5 + 10; int n, m; int a[maxn], b[maxn]; int calc() { memcpy(b, a, sizeof (int) * (n + 1)); sort(b + 1, b + n + 1, greater<int>()); int ret = 0; int cur = 1; b[0] = n + 1; b[n + 1] = 0; enum(i, 1, n + 1) { if(b[i] != b[i - 1]) { ret += max(b[i - 1] - b[i] - cur, 0); cur = 0; } cur ++; } return ret; } int main() { __init(); cin >> n >> m; enum(i, 1, n) cin >> a[i]; int x, y; while(m --) { cin >> x >> y; a[x] = y; cout << calc() << '\n'; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Snuke and Spells |
User | Jiangkp |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1709 Byte |
Status | WA |
Exec Time | 2103 ms |
Memory | 1792 KB |
Judge Result
Set Name | Sample | subtask | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | 0 / 500 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
subtask | sample1.txt, sample2.txt, sample3.txt, subtask_a1.txt, subtask_a2.txt, subtask_a3.txt, subtask_a4.txt, subtask_a5.txt, subtask_a6.txt, subtask_b1.txt, subtask_b2.txt, subtask_c1.txt, subtask_c2.txt, subtask_d1.txt, subtask_d2.txt, subtask_d3.txt, subtask_d4.txt, subtask_e1.txt, subtask_e2.txt, subtask_e3.txt, subtask_e4.txt, subtask_f1.txt, subtask_f2.txt |
All | sample1.txt, sample2.txt, sample3.txt, a1.txt, a2.txt, a3.txt, a4.txt, a5.txt, a6.txt, b1.txt, b2.txt, c1.txt, c2.txt, d1.txt, d2.txt, d3.txt, d4.txt, e1.txt, e2.txt, e3.txt, e4.txt, f1.txt, f2.txt, sample1.txt, sample2.txt, sample3.txt, subtask_a1.txt, subtask_a2.txt, subtask_a3.txt, subtask_a4.txt, subtask_a5.txt, subtask_a6.txt, subtask_b1.txt, subtask_b2.txt, subtask_c1.txt, subtask_c2.txt, subtask_d1.txt, subtask_d2.txt, subtask_d3.txt, subtask_d4.txt, subtask_e1.txt, subtask_e2.txt, subtask_e3.txt, subtask_e4.txt, subtask_f1.txt, subtask_f2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
a1.txt | TLE | 2103 ms | 1792 KB |
a2.txt | TLE | 2103 ms | 1792 KB |
a3.txt | TLE | 2103 ms | 1792 KB |
a4.txt | TLE | 2103 ms | 1792 KB |
a5.txt | TLE | 2103 ms | 1792 KB |
a6.txt | TLE | 2103 ms | 1792 KB |
b1.txt | TLE | 2103 ms | 1792 KB |
b2.txt | TLE | 2103 ms | 1792 KB |
c1.txt | TLE | 2103 ms | 1792 KB |
c2.txt | TLE | 2103 ms | 1792 KB |
d1.txt | TLE | 2103 ms | 1792 KB |
d2.txt | TLE | 2103 ms | 1792 KB |
d3.txt | TLE | 2103 ms | 1792 KB |
d4.txt | TLE | 2103 ms | 1792 KB |
e1.txt | TLE | 2103 ms | 1792 KB |
e2.txt | TLE | 2103 ms | 1792 KB |
e3.txt | TLE | 2103 ms | 1792 KB |
e4.txt | TLE | 2103 ms | 1792 KB |
f1.txt | TLE | 2103 ms | 1792 KB |
f2.txt | TLE | 2103 ms | 1792 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |
subtask_a1.txt | WA | 2 ms | 256 KB |
subtask_a2.txt | WA | 2 ms | 256 KB |
subtask_a3.txt | WA | 2 ms | 256 KB |
subtask_a4.txt | WA | 2 ms | 256 KB |
subtask_a5.txt | WA | 2 ms | 256 KB |
subtask_a6.txt | WA | 2 ms | 256 KB |
subtask_b1.txt | WA | 2 ms | 256 KB |
subtask_b2.txt | WA | 2 ms | 256 KB |
subtask_c1.txt | WA | 2 ms | 256 KB |
subtask_c2.txt | WA | 2 ms | 256 KB |
subtask_d1.txt | WA | 2 ms | 256 KB |
subtask_d2.txt | WA | 2 ms | 256 KB |
subtask_d3.txt | WA | 2 ms | 256 KB |
subtask_d4.txt | WA | 2 ms | 256 KB |
subtask_e1.txt | WA | 2 ms | 256 KB |
subtask_e2.txt | WA | 2 ms | 256 KB |
subtask_e3.txt | WA | 2 ms | 256 KB |
subtask_e4.txt | WA | 2 ms | 256 KB |
subtask_f1.txt | AC | 2 ms | 256 KB |
subtask_f2.txt | AC | 2 ms | 256 KB |