Submission #2147822
Source Code Expand
#include <bits/stdc++.h> #define REP(i, a, b) for(int i = (a); i < (b); i++) #define RREP(i, a, b) for(int i = (a); i >= (b); i--) #define pq priority_queue #define P pair<int, int> #define P2 pair<int, P> #define P3 pair<int, P2> typedef long long ll; typedef long double ld; using namespace std; const int INF = 1e9, MOD = 1e9+7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0}; const int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1}; const ld PI = abs(acos(-1)); const int sqrtN = 512; const int logN = 32; const ll LINF=1e18; int main(){ int n; cin >> n; int a[200010]; for(int i = 0; i < n; i++) cin >> a[i]; int c = 0; for(int i = 1; i < n; i++){ if(a[i - 1] <= a[i]) continue; int k = lower_bound(a, a + i, a[i]) - a; if(i - k <= a[i - 1] - a[i]){ for(int j = i; j > k; j--) swap(a[j], a[j - 1]), c++; }else{ c += a[i - 1] - a[i]; a[i] = a[i - 1]; } //for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl; } cout << c << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Increment and Swap |
User | ecasdqina |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1026 Byte |
Status | WA |
Exec Time | 2103 ms |
Memory | 1024 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1500 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, 057.txt, 058.txt, 059.txt, 060.txt, 061.txt, 062.txt, 063.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | TLE | 2010 ms | 1024 KB |
001.txt | TLE | 2103 ms | 1024 KB |
002.txt | TLE | 2103 ms | 1024 KB |
003.txt | TLE | 2103 ms | 1024 KB |
004.txt | TLE | 2103 ms | 1024 KB |
005.txt | TLE | 2103 ms | 1024 KB |
006.txt | TLE | 2103 ms | 1024 KB |
007.txt | TLE | 2103 ms | 1024 KB |
008.txt | TLE | 2103 ms | 1024 KB |
009.txt | TLE | 2103 ms | 1024 KB |
010.txt | TLE | 2103 ms | 1024 KB |
011.txt | TLE | 2103 ms | 1024 KB |
012.txt | TLE | 2103 ms | 1024 KB |
013.txt | TLE | 2103 ms | 1024 KB |
014.txt | TLE | 2103 ms | 1024 KB |
015.txt | TLE | 2103 ms | 1024 KB |
016.txt | TLE | 2103 ms | 1024 KB |
017.txt | TLE | 2103 ms | 1024 KB |
018.txt | TLE | 2103 ms | 1024 KB |
019.txt | TLE | 2103 ms | 1024 KB |
020.txt | TLE | 2103 ms | 1024 KB |
021.txt | WA | 35 ms | 384 KB |
022.txt | TLE | 2103 ms | 1024 KB |
023.txt | WA | 688 ms | 640 KB |
024.txt | WA | 148 ms | 384 KB |
025.txt | WA | 1594 ms | 768 KB |
026.txt | WA | 96 ms | 384 KB |
027.txt | TLE | 2103 ms | 896 KB |
028.txt | WA | 1181 ms | 512 KB |
029.txt | WA | 1291 ms | 512 KB |
030.txt | WA | 1635 ms | 512 KB |
031.txt | TLE | 2103 ms | 768 KB |
032.txt | TLE | 2103 ms | 640 KB |
033.txt | TLE | 2103 ms | 640 KB |
034.txt | TLE | 2103 ms | 896 KB |
035.txt | WA | 351 ms | 384 KB |
036.txt | TLE | 2103 ms | 896 KB |
037.txt | TLE | 2103 ms | 768 KB |
038.txt | WA | 557 ms | 384 KB |
039.txt | TLE | 2103 ms | 640 KB |
040.txt | TLE | 2103 ms | 640 KB |
041.txt | TLE | 2103 ms | 896 KB |
042.txt | AC | 75 ms | 1024 KB |
043.txt | TLE | 2103 ms | 1024 KB |
044.txt | TLE | 2103 ms | 1024 KB |
045.txt | AC | 1 ms | 256 KB |
046.txt | WA | 41 ms | 1024 KB |
047.txt | TLE | 2103 ms | 1024 KB |
048.txt | TLE | 2103 ms | 1024 KB |
049.txt | TLE | 2103 ms | 1024 KB |
050.txt | TLE | 2103 ms | 1024 KB |
051.txt | TLE | 2103 ms | 1024 KB |
052.txt | TLE | 2103 ms | 1024 KB |
053.txt | TLE | 2103 ms | 1024 KB |
054.txt | TLE | 2103 ms | 1024 KB |
055.txt | TLE | 2103 ms | 1024 KB |
056.txt | TLE | 2103 ms | 1024 KB |
057.txt | TLE | 2103 ms | 1024 KB |
058.txt | TLE | 2103 ms | 1024 KB |
059.txt | TLE | 2103 ms | 1024 KB |
060.txt | TLE | 2103 ms | 1024 KB |
061.txt | TLE | 2103 ms | 1024 KB |
062.txt | AC | 76 ms | 1024 KB |
063.txt | TLE | 2103 ms | 1024 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |