Submission #1111277

#TimeUsernameProblemLanguageResultExecution timeMemory
1111277TVSown Martian DNA (BOI18_dna)C++17
100 / 100
22 ms9020 KiB
///*** Sown_Vipro ***/// /// ->NHI QUOC GIA<- /// #include<bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") #define F first #define S second #define pb push_back #define pi pair<int, int> #define pii pair<int, pair<int, int> > #define FOR(i, a, b) for(int i = a; i <= b; ++i) #define REP(i, a, b) for(int i = a; i >= b; --i) #define all(s) s.begin(), s.end() #define szz(s) (s.size()) const string NAME = "sown"; const int N = 1e6 + 5, MAX = 1e6, oo = 1e9 + 5, MOD = 1e9 + 7; void maxi(int &x, int y){ if(x < y) x = y; } void mini(int &x, int y){ if(x > y) x = y; }; void add(int &x, int y){ x += y; x += MOD * (x < 0); x -= MOD * (x >= MOD); }; int n, k, r, res; int c[N], d[N], a[N]; void solve(){ cin >> n >> k >> r; FOR(i, 1, n){ cin >> a[i]; } int i = 1, j = 1; FOR(j, 1, r){ int b, q; cin >> b >> q; c[b] = q; while(i <= n + 1 && d[b] < c[b]){ ++d[a[i]]; ++i; } } if(i > n + 1){ cout << "impossible"; return; } while(d[a[j]] > c[a[j]]){ --d[a[j]]; ++j; } res = i - j; for(i; i <= n; ++i){ ++d[a[i]]; while(d[a[j]] > c[a[j]]){ --d[a[j]]; ++j; } res = min(res, i - j + 1); } cout << res; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // if(fopen((NAME + ".inp").c_str(), "r")){ // freopen((NAME + ".inp").c_str(), "r", stdin); // freopen((NAME + ".out").c_str(), "w", stdout); // } int t = 1; // cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

dna.cpp: In function 'void solve()':
dna.cpp:47:9: warning: statement has no effect [-Wunused-value]
   47 |     for(i; i <= n; ++i){
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...